Page 1 of 1

convert date

Posted: Tue Mar 25, 2003 10:40 pm
by valen53
hi, all
i face a problem, when i mkdate (), the date was increase a day.
such as i get today as $date_from.... 26/03/2003.
when i echo it...
echo date("m/d/Y", mktime($date_from)) ;
the date was 03/27/2003...

any method can be reduce the day?

Thank you for help.

Posted: Wed Mar 26, 2003 3:17 am
by twigletmac
It's showing you today's date because you are using the mktime() function incorrectly:

Code: Select all

mktime ( int hour, int minute, int second, int month, int day, int year ї, int is_dst])
Instead of doing this:

Code: Select all

$date_from = '26/03/2003'; 
echo date("m/d/Y", mktime($date_from));
you need to do something like:

Code: Select all

$date_from = explode('/', '26/03/2003');
$timestamp = mktime(0, 0, 0, $date_from[1], $date_from[0], $date_from[2]);
echo date('m/d/Y', $timestamp);
Mac