View Full Version : mktime() issue

05-31-2008, 12:37 PM
Hello, i got a smalldatetime value on mssql (e.g. 5/25/2008), wich is the date when the user subscribed, and i want to show on the website the subscription expire date. Now in order to do so, i should make something like this:

$time = explode("/", $dbdate);
$ftime = date("Y/n/d", mktime(0, 0, 0, $dbdate[0], $dbdate[1]+30, $dbdate[2]));

But it doesn't work because when i echo $dbdate it shows May 25 2008 instead of 5/25/2008, so, there's a problem with $dbdate[0] since the mkdate function won't work with the value "May".

Now, is there a way to "convert" the value "May" to "5"?

Thanks :)

06-02-2008, 03:36 PM
My suggestion is that you switch your format to integer, and you put in the unix timestamp as the value using the time() function

however to convert a human readable date into unix to use to convert "May" to 5 use the code below

$may = strtotime(human-readable);
$may = date(m, $may);

m = 01 thru 12 format (with leading zero)
n = 1-12 (no leading zero)