Monday, June 21, 2010

PHP: Compare Simple UTC timestamp with Ruby on Rails

In PHP

<?
echo gmdate("Y-m-d\TH:i:s\Z", time()); //2010-06-22T03:13:05Z

echo strtotime(gmdate("Y-m-d\TH:i:s\Z", time())); //1277176425
?>


In Ruby on Rails

<%= Time.now.utc %> # Tue Jun 22 03:13:05 UTC 2010

<%= Time.now.utc.to_i %> # 1277176425




If you find this useful, would you like to buy me a drink? No matter more or less, it will be an encouragement for me to go further. Thanks in advance!! =)

No comments:

Post a Comment