Showing posts with label conversion. Show all posts
Showing posts with label conversion. Show all posts

Friday, October 10, 2008

how to change month number to month name?

how to change month no to month name?
link 02 to february or Feb...

function month_name($month_no)
{
$timestmp = mktime(0,0,0,$month_no,1,2008);
return date("M",$timestmp);
}

echo month_name(10); //will return October
?>


Cheers!

Friday, May 30, 2008

Number to currency format conversion - Indian Rupees - in PHP

The following code can be used to convert the number format into indian currency format (Indian rupees, INR) using PHP.

<?php
ob_start();
//Currency format conversion - Indian Rupee
$n = "1000000";
$len = strlen($n); //lenght of the no
$num = substr($n,$len-3,3); //get the last 3 digits
$n = $n/1000; //omit the last 3 digits already stored in $num
while($n > 0) //loop the process - further get digits 2 by 2
{
$len = strlen($n);
$num = substr($n,$len-2,2).",".$num;
$n = round($n/100);
}
echo "Rs.".$num;
?>