View Full Version : convert 2012-01-08 16:13:54 to time()

01-08-2012, 01:40 PM
How do I convert the following format to unix time ?

2012-01-08 16:13:54

01-08-2012, 02:01 PM
First you need to explode the string by the space.

Then you need to explode the date by the /'s
Then you need to explode the time by the :'s

Then you need to re-arrange all those 6 variables and run them through mktime() (http://www.php.net/mktime)

You may also be able to feed it into strtotime() however that isn't as reliable (it won't take some timestrings according to the PHP versions and unlike most things, the php manual doesn't state which versions support what timestrings - EG "first day of <month>" doesn't appear to work below versions 5.3.0)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum