here i have a string date like this. 02/01/2009 : Format is DD/MM/YY
however my date.parse switches the month and the day.
how do i fix it.
irb(main):011:0> Date.parse("02/01/2009").strftime('%Y-%m-%d')
=> "2009-02-01"
here i have a string date like this. 02/01/2009 : Format is DD/MM/YY
however my date.parse switches the month and the day.
how do i fix it.
irb(main):011:0> Date.parse("02/01/2009").strftime('%Y-%m-%d')
=> "2009-02-01"
here i have a string date like this. 02/01/2009 : Format is DD/MM/YY
however my date.parse switches the month and the day.
how do i fix it.irb(main):011:0> Date.parse("02/01/2009").strftime('%Y-%m-%d')
=> "2009-02-01"
You can specify a format for the parse:
>> Date.strptime("02/01/2009", "%d/%m/%Y").to_s
=> "2009-01-02"
Hope that helps.
James Edward Gray II
On Jan 5, 2009, at 10:10 AM, Junkone wrote:
Junkone wrote:
here i have a string date like this. 02/01/2009 : Format is DD/MM/YY
however my date.parse switches the month and the day.
how do i fix it.irb(main):011:0> Date.parse("02/01/2009").strftime('%Y-%m-%d')
=> "2009-02-01"
Date.strptime("02/01/2009","%d/%m/%Y").to_s
=> "2009-01-02"
HTH,
Sebastian
--
NP: Mindcrime - Burning Glass (edit)
Jabber: sepp2k@jabber.org
ICQ: 205544826