J
jp
Hi,
I would like to get a timestamp from a Date object. What is the best
aproach for this?
thank you
I would like to get a timestamp from a Date object. What is the best
aproach for this?
thank you
I think you want a DateTime or Time object, I believe a Date object only represents a date, not a date andjp said:Hi,
I would like to get a timestamp from a Date object. What is the best
aproach for this?
thank you
Hi,
I would like to get a timestamp from a Date object. What is the best
aproach for this?
thank you
[Note: parts of this message were removed to make it a legal post.]
Don't know if this is what you're looking for but whenever I need a
serial-style timestamp (like for a filename). I just do this:
Time.now.strftime("%Y%m%d%H%M%S")
jp wrote:
represents a date, not a date and time unless perhaps 'date at midnight'
counts.
maybe...jp said:[Note: parts of this message were removed to make it a legal post.]
Don't know if this is what you're looking for but whenever I need a
serial-style timestamp (like for a filename). I just do this:
Time.now.strftime("%Y%m%d%H%M%S")
jp wrote:
Hi,
I would like to get a timestamp from a Date object. What is the best
aproach for this?
thank you
I think you want a DateTime or Time object, I believe a Date object only
represents a date, not a date and time unless perhaps 'date at midnight'
counts.
Hi,
It's enough to have the milliseconds since a given date in the past,
for example java has this:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html#getTime()
It's there anything comparable in Ruby?
Thanks
2009/11/19 jp said:[Note: =A0parts of this message were removed to make it a legal post.]
Don't know if this is what you're looking for but whenever I need a
serial-style timestamp (like for a filename). I just do this:
Time.now.strftime("%Y%m%d%H%M%S")
Hi,
It's enough to have the milliseconds since a given date in the past,
for example java has this:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html#getTime()
It's there anything comparable in Ruby?
Hint: there is documentation...
irb(main):001:0> Time.now.to_i
=3D> 1258647502
irb(main):002:0> Time.at(0)
=3D> 1970-01-01 01:00:00 +0100
irb(main):003:0> Time.at(0).to_i
=3D> 0
Cheers
robert
--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
2009/11/19 Robert Klemme said:2009/11/19 jp said:[Note: =A0parts of this message were removed to make it a legal post.]
Don't know if this is what you're looking for but whenever I need a
serial-style timestamp (like for a filename). I just do this:
Time.now.strftime("%Y%m%d%H%M%S")
Hint: there is documentation...
irb(main):001:0> Time.now.to_i
=3D> 1258647502
irb(main):002:0> Time.at(0)
=3D> 1970-01-01 01:00:00 +0100
irb(main):003:0> Time.at(0).to_i
=3D> 0
PS: I forgot
irb(main):007:0> t=3DTime.now
=3D> 2009-11-19 17:20:25 +0100
irb(main):008:0> t.to_i
=3D> 1258647625
irb(main):009:0> t.to_f
=3D> 1258647625.44141
irb(main):010:0> t.usec
=3D> 441411
Cheers
robert
--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.