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

  • SEARCH
  • Home
  • 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 8425195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:12:15+00:00 2026-06-10T04:12:15+00:00

From this answer , I’m using DateTime::Format::Strptime to grab the date from a string.

  • 0

From this answer, I’m using DateTime::Format::Strptime to grab the date from a string.

I’m using the following pattern: %m%d%Y%n%T. This should be matching:

  • %m: The month number (01-12). This will parse single digit numbers as well.
  • %d: The day of month (01-31). This will parse single digit numbers as well.
  • %Y: The year, including century (for example, 1991).
  • %n: Arbitrary whitespace.
  • %T: Equivalent to %H:%M:%S:
    • %H: The hour (00-23). This will parse single digit numbers as well.
    • %M: The minute (00-59). This will parse single digit numbers as well.
    • %S: The second (0-60; 60 may occur for leap seconds. See DateTime::LeapSecond).

However, on input: [05/18/2011 14:14:05] it’s failing with the error:

Your datetime does not match your pattern

As far as I can see, my pattern matches the input pattern. Where am I going wrong?

Relevant code is below:


use DateTime::Format::Strptime qw( );

my $format = DateTime::Format::Strptime->new(
   pattern   => '%m%d%Y%n%T',
   time_zone => 'local',
   on_error  => 'croak',
);

my $dt = $fields->[1] ;
print "Date:[$dt]\n";
my $dateopen = $format->parse_datetime($dt);

Output:

Date:[05/18/2011 14:14:05]
Your datetime does not match your pattern

  • 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-06-10T04:12:17+00:00Added an answer on June 10, 2026 at 4:12 am

    The non-pattern characters are important as well. You have slashes between your date components, hence the pattern '%m/%d/%Y%n%T' works while yours doesn’t.

    Note that the pattern %D would not work either as it is a shortcut for %m%d%Y and doesn’t include the slashes either.

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

Sidebar

Related Questions

I'm using the following code from this answer Sending email in .NET through Gmail
From This answer and the fact i may be using an anti pattern I
I am using the accepted answer from this question . The relevant code is
I am trying to integrated linkedIn using this question answer Posting LinkedIn message from
I am using the script from this answer https://stackoverflow.com/a/1681410/22 to insert a launch application
Taken from this answer here : static const qi::rule<std::string::iterator, ast_t()> node = '{' >>
Following on from this answer , it seems these constructors: template<class U, class V>
Following on from this answer , I am having a spot of bother with
Using the code from this answer: https://stackoverflow.com/a/9744961/514773 I've noticed that any time I enter:
I tried using the answer involving git-filterbranch from this question Combining multiple git repositories

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.