Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Converting a date to mysql format

Reply
Thread Tools

Converting a date to mysql format

 
 
Crustov
Guest
Posts: n/a
 
      04-07-2009
Is there an easy way to convert '13-Mar-2009 20:55 PDT' into something
that ruby understands, so that I can output it in a format that mysql
understands?
 
Reply With Quote
 
 
 
 
Joel VanderWerf
Guest
Posts: n/a
 
      04-07-2009
Crustov wrote:
> Is there an easy way to convert '13-Mar-2009 20:55 PDT' into something
> that ruby understands, so that I can output it in a format that mysql
> understands?


require 'time'
t = Time.parse '13-Mar-2009 20:55 PDT'
t.strftime("%Y-%m-%d") # => "2009-03-13"

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

 
Reply With Quote
 
 
 
 
Crustov
Guest
Posts: n/a
 
      04-07-2009
On Apr 7, 12:26*pm, Joel VanderWerf <vj...@path.berkeley.edu> wrote:
> Crustov wrote:
> > Is there an easy way to convert '13-Mar-2009 20:55 PDT' into something
> > that ruby understands, so that I can output it in a format that mysql
> > understands?

>
> require 'time'
> t = Time.parse '13-Mar-2009 20:55 PDT'
> t.strftime("%Y-%m-%d") *# => "2009-03-13"
>
> --
> * * * *vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407


Awesome. Thanks.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
howto Date Time string from MYSQL to German Format sanitarysystems@googlemail.com Perl Misc 1 10-21-2007 12:54 PM
how can i use regular expressions to ensure a mysql format date entry in a text field? libsfan01 Javascript 8 10-12-2006 01:56 PM
displaying the date in mysql format for insertion into db libsfan01 Javascript 1 06-13-2006 09:03 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57