The strftime
docs claim that %Q
works:
%Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
But it returns "%Q" for me.
2.1.1 :054 > date = Time.now
=> 2014-06-10 12:28:57 -0700
2.1.1 :055 > date.strftime("%Q")
=> "%Q"
I'm using RVM and Ruby 2.1.1.
Am I doing something wrong, or is this a Ruby bug?
You're declaring a Time
object, not a Date
or DateTime
object. Time
's behavior is entirely different from Date
or DateTime
's.
Try this instead:
require 'date'
Date.today.strftime("%Q")
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With