简体   繁体   中英

How to convert human-readable date string back into time

My website uses the following code:

$a1="1293011062"; // hex code umm i think !
$expires = date('M d, Y', $a1);
echo $expires; // Output Dec 22, 2010

How can I do the reverse operation? That is, what if i want to convert Apr 06, 2012 to hex, the way it's represented in a1 ?

You can use strtotime: http://us2.php.net/strtotime and that isn't hex

<?php
$a1="1293004800";
$expires = date('M d, Y', $a1);
echo $expires . "<br/>"; // Output Dec 22, 2010

echo strtotime($expires); // 1293004800
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM