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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:25:12+00:00 2026-05-23T21:25:12+00:00

I using PHP’s strtotime function for converting date from one format to another i

  • 0

I using PHP’s strtotime function for converting date from one format to another
i have the following

$date = "12-22-2011";

 echo $newDateFormat = date("Y-m-d", strtotime($date) );

// Output 1970-01-01
// But when i replace "-"  with "/" I get proper output
$date = "12/22/2011";

echo $newDateFormat = date("Y-m-d", strtotime($date) );

// Output 2011-12-22 

Why so ?
or is there any other function which accepts anything and convert to proper date format ?

  • 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-23T21:25:12+00:00Added an answer on May 23, 2026 at 9:25 pm

    From the strtotime documentation:

    Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

    Essentially, hyphenated dates are assumed to be d-m-y, and never m-d-y.

    For customised parsing, use DateTime::createFromFormat().

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

Sidebar

Related Questions

Using PHP how can I get week's start date and end date from any
Using PHP, is it possible to select multiple rows from one table, in a
using PHP and MySQL i have grabbed an array of facebook user ids from
Using PHP and MySQL, I have a forum system I'm trying to build. What
using php and mysql I have two tables, a users table and a profiles
Using PHP's Image and GD functions you can use the following method to finally
Using PHP I'd like to compare an actual ip address to part of one,
Using PHP I'm attempting to take an HTML string passed from a WYSIWYG editor
Using PHP / MySQL all encoded up as UTF, we have recently had to
Using PHP, is there a function/method/way to check if a variable contains something that

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.