Jump to content

[SOLVED] converting a date format (dd/mm/yyyy) into a time() format


psychohagis

Recommended Posts

Does anyone have anymore knowledge on this because I have explored the function mentioned above but I have on problem.

 

According to the manual it will convert any english date into a time() type format. but thats not quite true.

In england dd/mm/yyyy is standard but if you put in a date that is formatted like that it assumes it is mm/dd/yyyy which is the american format.

Is their anyway I can tell strtotime() that its dd/mm/yyyy instead of mm/dd/yyyy ??

 

thanks in advance

If you explode the date you can use the mktime() function.

 

http://us2.php.net/mktime

 

//int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] )
list($day,$month,$year) = explode("/", $date);

$unixTime = mktime(0,0,0,$month,$day,$year);

  • 1 year later...

i just thought I would mention that another thing you could do is parse the date into an array using the date_parse() method.

 

I was looking for a way to reformat a MYSQL timestamp string and this (date_parse($row["date"]);) worked perfectly.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.