Created
November 5, 2012 16:15
Revisions
-
moklett revised this gist
Nov 5, 2012 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -50,3 +50,17 @@ irb(main):001:0> require 'time' irb(main):002:0> t = Time.parse("Mon, 05 Nov 2012 16:39:09 +0000") => 2012-11-05 11:39:09 -0500 ``` ### Parsing with PHP ```php php > date_default_timezone_set("UTC"); php > $t = new DateTime("Mon, 05 Nov 2012 16:39:09 +0000"); php > echo date_format($t, "Y-m-d H:i:s"); 2012-11-05 16:39:09 php > echo date_format($t, "Y-m-d H:i:s e"); 2012-11-05 16:39:09 +00:00 php > $t->setTimezone(new DateTimeZone("America/New_York")); php > echo date_format($t, "Y-m-d H:i:s e"); 2012-11-05 11:39:09 America/New_York ``` -
moklett revised this gist
Nov 5, 2012 . 1 changed file with 29 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ # Unix Timestamp (Seconds since epoch) ### Generating from Ruby ```ruby t = Time.now @@ -12,8 +13,7 @@ tu.to_i # => 1352131945 ``` ### Parsing with PHP ```php php > date_default_timezone_set("UTC"); @@ -25,4 +25,28 @@ php > echo date_format($t, "Y-m-d H:i:s e"); php > $t->setTimezone(new DateTimeZone("America/New_York")); php > echo date_format($t, "Y-m-d H:i:s e"); 2012-11-05 11:12:25 America/New_York ``` # RFC 2822 ### Generating from Ruby (w/ ActiveSupport) ```ruby >> t = Time.now => Mon Nov 05 11:39:09 -0500 2012 >> tu = t.utc => Mon Nov 05 16:39:09 UTC 2012 >> t.to_s(:rfc822) => "Mon, 05 Nov 2012 16:39:09 +0000" >> tu.to_s(:rfc822) => "Mon, 05 Nov 2012 16:39:09 +0000" ``` ### Parsing with Ruby ```ruby irb(main):001:0> require 'time' => true irb(main):002:0> t = Time.parse("Mon, 05 Nov 2012 16:39:09 +0000") => 2012-11-05 11:39:09 -0500 ``` -
moklett revised this gist
Nov 5, 2012 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ Ruby ---- ```ruby t = Time.now # => 2012-11-05 11:12:25 -0500 @@ -9,6 +12,9 @@ tu.to_i # => 1352131945 ``` PHP --- ```php php > date_default_timezone_set("UTC"); php > $t = new DateTime("@1352131945"); -
moklett revised this gist
Nov 5, 2012 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,4 +16,7 @@ php > echo date_format($t, "Y-m-d H:i:s"); 2012-11-05 16:12:25 php > echo date_format($t, "Y-m-d H:i:s e"); 2012-11-05 16:12:25 +00:00 php > $t->setTimezone(new DateTimeZone("America/New_York")); php > echo date_format($t, "Y-m-d H:i:s e"); 2012-11-05 11:12:25 America/New_York ``` -
moklett created this gist
Nov 5, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ ```ruby t = Time.now # => 2012-11-05 11:12:25 -0500 t.to_i # => 1352131945 tu = t.utc # => 2012-11-05 16:12:25 UTC tu.to_i # => 1352131945 ``` ```php php > date_default_timezone_set("UTC"); php > $t = new DateTime("@1352131945"); php > echo date_format($t, "Y-m-d H:i:s"); 2012-11-05 16:12:25 php > echo date_format($t, "Y-m-d H:i:s e"); 2012-11-05 16:12:25 +00:00 ```