• how do i convert this comma delimited string to date object?

    From jacki@21:1/5 to Junkone on Tue Sep 6 09:12:48 2016
    W dniu 2016-09-02 o 18:48, Junkone pisze:
    I have a string with date and time that are comma delimited in this format. how do I convert it to date object?
    2013-10-02, 4:30am


    2.2.0 :008 > require 'time'
    true
    2.2.0 :012 > Date.parse('2013-10-02, 4:30am')
    #<Date: 2013-10-02 ((2456568j,0s,0n),+0s,2299161j)>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From pratap477@gmail.com@21:1/5 to Junkone on Fri Oct 21 03:08:32 2016
    On Friday, September 2, 2016 at 10:18:36 PM UTC+5:30, Junkone wrote:
    I have a string with date and time that are comma delimited in this format. how do I convert it to date object?
    2013-10-02, 4:30am

    Use Time.parse instead of the date parse.
    require 'time'
    Time.parse('2013-10-02, 4:30am')

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Junkone@21:1/5 to All on Fri Sep 2 09:48:28 2016
    I have a string with date and time that are comma delimited in this format. how do I convert it to date object?
    2013-10-02, 4:30am

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hasan Diwan@21:1/5 to Junkone on Fri Sep 2 18:19:31 2016
    Junkone <junkone1@gmail.com> writes:

    I have a string with date and time that are comma delimited in this format. how do I convert it to date object?

    DateTime.strptime('2013-10-02, 4:30am', '%Y-%m-%d, %H:%M%p')

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)