Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3977794
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:57:58+00:00 2026-05-20T04:57:58+00:00

Need help parsing the datetime stamp and splitting it up by date and time.

  • 0

Need help parsing the datetime stamp and splitting it up by date and time.

use strict;
use warnings;
use Time::Piece;

my $string = "05:57:03 08/31/10 MDT";

print $string,"\n";

my $time = Time::Piece->strptime($string, "%H:%M:%S");
my $date = Time::Piece->strptime($string, "%Y/%m/%d");

print $time,$date,"\n";

Thanks! Also how do I figure out which day of week this is using code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:57:58+00:00Added an answer on May 20, 2026 at 4:57 am

    You should be able to use code like the following:

    my $t = Time::Piece->strptime($string, "%H:%M:%S %m/%d/%y %Z");
    

    However, on my system at least, I have to change the time zone MST to GMT for it to match; if I leave it as in your example, I get an error:

    Perl> my $t = Time::Piece->strptime("05:57:03 08/31/10 DST", "%H:%M:%S %m/%d/%y %Z");
    [!] Runtime error: Error parsing time at /usr/local/lib/perl/5.10.0/Time/Piece.pm line 469.
    

    If it works for you, though, you’ll have a Time::Piece object, on which you can call e.g. $t->day_of_week for the day of the week as a number, $t->day for e.g. ‘Tue’, or $t->fullday for e.g. ‘Tuesday’.

    See the documentation for Time::Piece for details on the methods you can call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with parsing a string in Linux. I have a string:
I need help with parsing json string in Java Android Appl. Text of JSON
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
I need help to replace all \n (new line) caracters for in a String,
I'm currently using json-framework and need some help though parsing some JSON i'm getting
i need help modelling a use case diagram from a topic, it will be
I'm really need help with parsing XML by TBXML. I created a demo project
I need help with parsing of JSON feed text returned from Twitter. I need
I need some help with parsing the response from ListDirectoryDetails in C#. I only
i need help parsing a response with the jackson mapper to a POJO. i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.