in reply to Get current time using Joda time format

Try DateTime::Format::Strptime? Time::Piece::strptime?
  • Comment on Re: Get current time using Joda time format

Replies are listed 'Best First'.
Re^2: Get current time using Joda time format
by Corion (Patriarch) on Mar 24, 2017 at 07:15 UTC

    Shouldn't it be strftime instead of strptime? I get the impression that ravi45722 has the format string and wants to produce the current date+time according to that format.

    But the modules work in both directions, resp. DateTime has formatters, so the module suggestions are still good no matter the direction of conversion.

Re^2: Get current time using Joda time format
by ravi45722 (Pilgrim) on Mar 24, 2017 at 10:17 UTC
    my $t = Time::Piece->strptime("Friday 24rd Mar, 2017", "%A %drd %b, % +Y"); print $t->strftime("%a %b %d %H:%m:%s %Y");

    gives something like this

     "Fri Mar 24 11:54:55.234 2017"

    But I need that as print

     $t->strftime("EEE MMM dd HH:mm:ss.SSS yyyy");

    Is there any module like that????

    I dont have unix format. I have only joda time format string

      It isn't clear to me how your problem hasn't been solved here, sorry. Perhaps you could re-state it in the form of a test so that everyone can see the issue? See How to ask better questions using Test::More and sample data for how to present that. Once we can understand what you are asking we will be better positioned to suggest some solution.

      Update: A thought: is it the case that you aren't interested in formatting the time but actually you want to re-format the format? ie. convert from Joda format specifiers to strftime specifiers?