Hi,
Date.parse(“28/03/2008”) gives me an error?
I get:
ArgumentError: invalid date.
Any ideas how to fix this?
Versions:
Ruby 1.8.6
Rails 2.0.2
Hi,
Date.parse(“28/03/2008”) gives me an error?
I get:
ArgumentError: invalid date.
Any ideas how to fix this?
Versions:
Ruby 1.8.6
Rails 2.0.2
Hello,
On Sun, Jun 8, 2008 at 12:35 PM, Greg H.
[email protected] wrote:
Date.parse(“28/03/2008”) gives me an error?
Try:
Date.parse(“03/28/2008”)
but that’s not the format I get the data in I’m in Australia.
Any ideas?
On Jun 8, 12:04 am, Greg H. [email protected]
wrote:
Date.parse(“28/03/2008”) gives me an error?
Try:
Date.parse(“03/28/2008”)
–
Nico
Perhaps this link I found can be of use:
http://source.mihelac.org/2006/9/13/parsing-european-date-format-in-ruby-rails
On Jun 7, 2008, at 9:43 PM, [email protected] wrote:
On Sun, Jun 8, 2008 at 12:35 PM, Greg H.
Perhaps this link I found can be of use:
http://source.mihelac.org/2006/9/13/parsing-european-date-format-in-ruby-rails
That would work, but so would this:
Date.strptime(‘28/03/2008’, ‘%d/%m/%Y’)
Ray
Greg H. wrote:
excellent thanks,
You’d think Ruby would provide some internationalisation type way of
solving
this? (e.g. specifying your location/country or something). Guess not?
Hello,
Unfortunately for me, the solution by Ray doesn’t seem to work too. For
instance I’m doing this…
dateStr = params[:startdate].to_s
logger.info "date - " + dateStr
startdate =Date.strptime(dateStr, ‘%m/%d/%Y’).to_s
and though I get the string quite correctly as
date - 05/16/2008
I end up getting the ArgumentError - invalid date. Please let me know if
I am doing anything incorrect here.
Regards,
Shankar.
excellent thanks,
You’d think Ruby would provide some internationalisation type way of
solving
this? (e.g. specifying your location/country or something). Guess not?
Mark T. wrote:
I end up getting the ArgumentError - invalid date. Please let me know if
I am doing anything incorrect here.Doesn’t look like it.
Date.strptime(“05/16/2008”, ‘%m/%d/%Y’).to_s
works for me.
Does it have anything to do with the version of Ruby/Rails ? I’m using
Rails 1.1.6 and Ruby 1.8.4. Another wierd thing about this is
dateStr.to_time works while dateStr.to_date again gives me the same
exception.
On Jun 25, 10:31 am, Shankar N. [email protected] wrote:
Rails 1.1.6 and Ruby 1.8.4. Another wierd thing about this is
dateStr.to_time works while dateStr.to_date again gives me the same
exception.
It might. I’m using 1.8.6
I end up getting the ArgumentError - invalid date. Please let me know if
I am doing anything incorrect here.
Doesn’t look like it.
Date.strptime(“05/16/2008”, ‘%m/%d/%Y’).to_s
works for me.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs