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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:45:28+00:00 2026-05-21T21:45:28+00:00

I have looked in the manuals, It is probably a conversion weirdness but I

  • 0

I have looked in the manuals, It is probably a conversion weirdness but I cannot figure it out. I am getting a date from the user and attempting to validate it in PHP (version 4.1) (using strtotime and checking the return value). The users will be entering the date in European format (d-m-y) but when I supply this format date to strtotime it is inconsistent eg :

03-01-2011 is converted to the 3rd of July 2008

I know the manual says that a hyphen or dot separated date is interpreted as European but it is not working here.

$startDate=$_GET['start'];
echo $startDate;
$timestamp=strtotime($startDate);
echo $timestamp;
echo date("d-M-Y",$timestamp);

the output from the first echo is 03-01-2011 (this is correct – the user entered value), the second echo shews the timestamp as being 1215039600 and the date echo shews 03-Jul-2008

  • 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-21T21:45:29+00:00Added an answer on May 21, 2026 at 9:45 pm

    strtotime is magical, but it’s not infallible. If you want to guarantee a proper conversion, you should use

    $dt = DateTime::CreateFromFormat('d-m-Y', $startDate);
    

    which lets you specify explicity formats for the input so there’s no ambiguity.

    Unfortunately, this is PHP 5.3+ only, and you’re stuck on 4.1. Even strfptime() which works similary only came in at 5.1

    I’d strongly suggest updating your PHP version, as 4.x is deprecated and unsupported.

    That being said, I can’t see how any kind of conversion ambiguity would convert 2011 into 2008. Timezone differences and day/month oddness would throw off hours and months, but not change things by 3 years.

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

Sidebar

Related Questions

I have looked all over and cannot figure out why this code isn't working.
I've looked around and cannot figure this one out: I have a object that
Have looked quite hard for this answer but having no luck. I have 3
I have looked but have not found a specific answer for changing just one
I have looked here and from what I understand the following regex simply means
I have looked thoroughly, but I have not found the solution (or perhaps I
How can I send MIDI messages out from a C++ program and have them
I have looked at many other threads that show how to use accelerometer values,
I have looked at questions like this , this , this and this ,
I have looked on the web to find a list of all Python keywords

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.