Created
March 6, 2015 10:15
-
-
Save rahim/f657a9dc75f1dc82a772 to your computer and use it in GitHub Desktop.
ISO8601 millisecond handling in Ruby 2.1.5
This file contains 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 characters
2.1.5 (main):0 > Time.now.strftime('%Y-%m-%d %H:%M:%S.%L') | |
=> "2015-03-06 10:09:12.974" | |
2.1.5 (main):0 > str = Time.now.strftime('%Y-%m-%d %H:%M:%S.%L') | |
=> "2015-03-06 10:09:26.497" | |
2.1.5 (main):0 > Time.parse(str) | |
=> 2015-03-06 10:09:26 +0000 | |
2.1.5 (main):0 > t = Time.parse(str) | |
=> 2015-03-06 10:09:26 +0000 | |
2.1.5 (main):0 > t.strftime('%Y-%m-%d %H:%M:%S.%L') | |
=> "2015-03-06 10:09:26.497" | |
2.1.5 (main):0 > str = Time.now.strftime('%F %T.%L') | |
=> "2015-03-06 10:14:05.369" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment