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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:30:56+00:00 2026-06-03T14:30:56+00:00

I have a database that has a few unknown months or days formatted like

  • 0

I have a database that has a few unknown months or days formatted like so: 1999-01-00 / 1999-00-00.

Now, I’ve been using DateTime() to format the days that are full, which works fine.

I’d like to have abbreviations for unknown days, but known months using $DateTime->format('M Y'); which outputs Sep 1999

and

$DateTime->format('Y'); for 1999 that is for unknown months and days.

DateTime() Doesn’t allow 00 values for months/days, so what are some ways to get around this?

  • 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-03T14:30:58+00:00Added an answer on June 3, 2026 at 2:30 pm

    Unfortunately, the DateTime class is pretty much a wrapper for a UNIX timestamp. (I said pretty much, I know there’s more to it than just that.) The way that it works with dates were one of the elements is zero is simply to calculate it as a synonym for the previous period. (e.g.: April 0 is calculated to become March 31.)

    Really, you just have to bypass PHP’s built in date functionality and write your own. The good news is that you can indeed do this. MySQL will actually return values as simple strings, and, when it comes to dates, the natural response that the actual C libraries use is to return the date pretty much as an ISO 8601 string. (There’s that phrase pretty much again.)

    If I were writing this, I would read the value raw with mysql_fetch_row (or your own method) and check if all the elements (i.e.: year, month, day) are defined. If they are, use the DateTime method. If not, I would write a piece of code to pull apart the elements that are defined and format it accordingly.

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

Sidebar

Related Questions

I have to restore a database that has been inadvertently DROPped in MySQL 5.0.
I have a MySQL database that has a few very simple tables. I would
I have a database that has few tables and views. Views are combination of
I have a split access 2007 database that has been running fine on a
I have a table that has been generated dynamically using PHP. The table has
i have a database that has a few hundred tables i need to find
I have a database that is currently using AES 128. The database has about
I am using the telerik MVC template and have a database that has a
I have a database that has node & nodetype tables. Nodes table NodeID ParentNodeID
I have an existing database that has some testing data into and I'm interested

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.