Converting a date to mysql format

Discussion in 'Ruby' started by Crustov, Apr 7, 2009.

  1. Crustov

    Crustov Guest

    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?
     
    Crustov, Apr 7, 2009
    #1
    1. Advertising

  2. 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
     
    Joel VanderWerf, Apr 7, 2009
    #2
    1. Advertising

  3. Crustov

    Crustov Guest

    On Apr 7, 12:26 pm, Joel VanderWerf <> 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.
     
    Crustov, Apr 7, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bogdan Zamfir

    Converting date value to US format

    Bogdan Zamfir, Aug 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,460
    Michal A. Valasek
    Aug 18, 2003
  2. Gary Smith

    Converting to different date format.....

    Gary Smith, Feb 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    432
    Teemu Keiski
    Feb 14, 2004
  3. Brian Candy
    Replies:
    2
    Views:
    1,172
    Janaka
    Feb 18, 2004
  4. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,278
    Michael Borgwardt
    May 30, 2004
  5. Fei Liu
    Replies:
    21
    Views:
    2,378
    John Bokma
    Dec 16, 2006
Loading...

Share This Page