views:

121

answers:

3

How can i convert 2010-03-01 to unixtime like 1267452738

+5  A: 
echo strtotime('2010-03-01');
John Conde
thanks have a nice day
streetparade
A: 

From http://php.net/manual/en/function.strtotime.php:

strtotime (PHP 4, PHP 5) — Parse about any English textual datetime description into a Unix timestamp

int strtotime ( string $time [, int $now ] )

The function expects to be given a string containing a US English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in now , or the current time if now is not supplied.

This function will use the TZ environment variable (if available) to calculate the timestamp. Since PHP 5.1.0 there are easier ways to define the timezone that is used across all date/time functions. That process is explained in the date_default_timezone_get() function page.

David Pfeffer
A: 

http://www.onlineconversion.com/unix_time.htm is also a good resource to convert unix time to date and vice versa.

Atul