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 6136487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:36:32+00:00 2026-05-23T17:36:32+00:00

All I need is to compare dates represented by string values in the format

  • 0

All I need is to compare dates represented by string values in the format d.m.y (e.g. 15.07.11 for today).

strtotime unfortunatelly gives me wrong results (probably because of the format). I found a answer to my question (PHP strtotime incorrect conversion) but DateTime::CreateFromFormat is not available in my PHP version. I could not find strfptime but think the autor of the answer meant strptime. The result of strptime is a array. I was surprised that I can compare arrays but the compare result is not valid.

What would be the easiest way to compare dates in the given string format with PHP <= 5.1.6?

  • 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-23T17:36:32+00:00Added an answer on May 23, 2026 at 5:36 pm

    You could always pass the result of strptime to mktime and get a usable Unix timestamp which you can compare or feed to the DateTime objects.

    <?php
        $d = strptime('15.07.11', '%d.%m.%y');
        $timestamp = mktime($d['tm_hour'], $d['tm_min'], $d['tm_sec'], $d['tm_mon'], $d['tm_mday'], 1900 + $d['tm_year']);
        echo date("j F Y", $timestamp);
    ?>
    

    The only thing to watch for is that strptime gives the year as the number of years since 1900, and mk_time just takes a year number, so I added 1900 to it.

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

Sidebar

Related Questions

I have two time values in HH:mm format that I need to compare, and
First of all, I don't need a textual comparison so Beyond Compare doesn't do
I've got a reasonably simple query (this time) that I need ALL the results
I need to compare two dates to show an edit link if it is
bash master needed... To compare mysqldumps from multiple dates, I need sql GROUP BY,
In my code I need to find all my things that happened today. So
I need to compare two calendar dates. I wrote the javascript function too. But
I have multiple threads who all need to write to the same Dictionary. I
I have multiple threads (C# application running on IIS) running that all need to
All I need is a way to make a property of one class only

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.