2012-04-06 44 views
0

我的網站使用下面的代碼:如何人類可讀的日期字符串轉換回時間

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

我該怎麼做反向操作?也就是說,如果我想將Apr 06, 2012轉換爲十六進制,它代表的方式是a1

+0

這是自1970年1月1日(AKA UNIX時間戳),過去的秒數,而不是一個「十六進制代碼 – 2012-04-06 17:53:45

+0

@VincentSavard哦!真的!我認爲這是一種加密〜非常感謝 – 2012-04-06 17:55:36

回答

1

可以使用的strtotime:http://us2.php.net/strtotime,因此不咒

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

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