Jump to content

Convert a date to UNIX timestamp?


markvaughn2006

Recommended Posts

sorry, I know this is simple, but stuck on it...

 

how would one go about converting 1/21/11 to a UNIX timestamp, something like 1293035229?

 

and while we are at it, how to convert 1293035229 to 1/21/11 ? (i know the timestamp is wrong, just for example)

 

 

THX!!!!!

Link to comment
https://forums.phpfreaks.com/topic/222417-convert-a-date-to-unix-timestamp/
Share on other sites

<?php
$not_unix = "12/01/01";
$unix = strtotime($not_unix);

echo $unix;
?>

 

edit:

just be careful of some traps like "MM/DD/YY" vs "YY/MM/DD" or "mm/dd/yy" vs "mm-dd-yy"

 

check out the docs and comments at php.net/strtotime

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.