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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:58:20+00:00 2026-06-15T15:58:20+00:00

Hopefully someone can answer this. Running this piece of code: $date = 2nd January,

  • 0

Hopefully someone can answer this.

Running this piece of code:

$date = "2nd January, 2013"; 
echo date("Y-m-d",strtotime($date));

Which returns:

2012-01-02.

Which clearly is not correct (or at least the results i’m hoping for)

Now based on some online research, this may possibly be passing it as time, rather then year. Is there a way to manage this, or do you have to supply dates in an american format for it to return correctly?

  • 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-15T15:58:21+00:00Added an answer on June 15, 2026 at 3:58 pm

    According to PHP’s acceptable date string format, comma is only acceptable in Textual month, day and year format: m ([ .\t-])* dd [,.stndrh\t ]+ y

    So you’ll have to either switch the position of month and day, or get rid of the comma:

    echo date("Y-m-d",strtotime("2nd January, 2013")); //outputs "2012-01-02"
    echo date("Y-m-d",strtotime("2nd January 2013")); //outputs "2013-01-02"
    echo date("Y-m-d",strtotime("January 2nd, 2013")); //outputs "2013-01-02"
    

    codepad paste

    I guess the reason the first statement returns 2012 is because characters after the comma are ignored, so the string is actually treated as 2nd January, and the current year is then assumed.

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

Sidebar

Related Questions

Hopefully someone can help with this, I can't find the answer anywhere! I'm currently
This is a weird one, but hopefully someone can give me an idea here.
Hopefully someone knows the answer to this Java-Certification question: public static void main(String[] args)
Have seen multiple posts on this but I can't see any which answer my
Hopefully this should be an easy answer for someone out there (and possibly a
hopefully someone here will find the answer to this: Im looking to have a
This is my first question on stackoverflow, hopefully there is someone who can help
Hopefully someone can help here, it's incredibly frustrating! I have a couple of iOS
Hopefully someone can help me. I'm attempting to do the following: If a user
Quick question hopefully someone can help out here. I'm trying to copy and paste

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.