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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:48:53+00:00 2026-05-31T10:48:53+00:00

I am writing a project with considerable date handling in PHP. In doing so,

  • 0

I am writing a project with considerable date handling in PHP. In doing so, I wrote a piece of code that was consistently malfunctioning, making use of PHP’s date() function. I have isolated the code (the rest of the code in the project is irrelevant), and here it is:

<?php
    date_default_timezone_set("GMT");
    echo date("F m, Y g:ia",strtotime("April 15, 2012 10:00am"));
    //Output: April 04, 2012 10:00am
    //Should be: April 15, 2012 10:00am
?>

In theory (I think), this code should calculate the timestamp of April 15, 2012, at 10:00 in the morning. This seems to be happening correctly. The date() function should then turn that back into a human-readable date in the same format that was input. It doesn’t, though. It outputs April 04, 2012 10:00am. In May, it says May 5th; in June, June 6th. So I think there is some bug that makes it confuse the day of the month with the month itself.

On the other hand, it could be some weird problem that I didn’t ever consider. I’m looking for second opinions/”you’re so stupid you’re doing X wrong”s. If it is a bug, I’ll report it. I have trouble believing it’s a bug, since with these dates coming up so soon I would think that it would have been noticed by now.

  • 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-31T10:48:54+00:00Added an answer on May 31, 2026 at 10:48 am

    http://php.net/manual/en/function.date.php

    No, you’ve just messed up your date format string – F m means “Month (textual) Month (numeric) – it’s printing 04 because that’s the month number for April.

    You want a j instead to print the day of the month:

    echo date("F j, Y g:ia",strtotime("April 15, 2012 10:00am")); // prints "April 15, 2012 10:00am" as expected.
    

    Any time you think you’ve detected a bug in the tools take a VERY long look at your code!

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

Sidebar

Related Questions

When writing PHP code for any given project, do you find you can write
I am writing a project that reads a file and sorts Words. This code
I am writing my first project that will use autoconf and teaching it to
I'm writing a project in php that will basically give me a webpage with
When writing code in an Eclipse project, I'm usually quite messy and undisciplined in
I am writing a project that takes advantage of the hiredis redis client library.
i'm writing project that stores data, so i need to compress it. I've tried
I am currently writing a project where I make a heavy use of ListT
I'm working in a Scrum project writing firmware code in C for an ASIC.
I'm relatively new to PHP and have been writing a project using what I

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.