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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:38:05+00:00 2026-06-15T18:38:05+00:00

I am encountering a slightly frustrating problem and I have a feeling there is

  • 0

I am encountering a slightly frustrating problem and I have a feeling there is a simple solution to it. When I pass the same UNIX timestamp to the PHP date and MySQL FROM_UNIXTIME methods they are returning two very different dates. I would like to return a value from MySQL that matches the one returned by PHP.

Here is the code I am currently using along with it’s output. The timestamp provided represents the date Tue, 01 Jan 2013 (01/01/2013). Also for reference, here are the format values.

MySQL Format

  • %j = Day of year (001..366).
  • %m = Month, numeric (00..12).
  • %y = Year, numeric (two digits).

PHP Format

  • z = The day of the year starting from 0 (0 through 365).
  • m = Numeric representation of a month, with leading zeros (01 through 12).
  • y = A two digit representation of a year (Examples: 99 or 03).

MySQL Query

SELECT FROM_UNIXTIME(1357018200, '%j-%m-%y');
-> 366-12-12

PHP Code

echo date('z-m-y', 1357018200);
-> 0-01-13

Any help would be greatly appreciated, thanks for your time. 🙂

Other Information

  • MySQL Version: 5.5.23
  • MySQL system_time_zone: CDT
  • MySQL time_zone: SYSTEM
  • PHP date_default_timezone_get: America/Chicago (CDT)
  • 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-15T18:38:06+00:00Added an answer on June 15, 2026 at 6:38 pm

    Your PHP and MySQL aren’t agreeing on the time. Using the time converter at:

    http://www.4webhelp.net/us/timestamp.php?action=stamp&stamp=1357018200&timezone=-6

    gives the result “Monday, December 31st 2012, 23:30:00 (GMT -6)” so your PHP is giving the wrong result. Although you’ve given the timezone that PHP is running in, can you double check by running:

    date_default_timezone_set ("America/Chicago");
    echo date('z-m-y', 1357018200)."\r\n";
    

    Which should give “365-12-12”.

    I guess it’s possible either something is setting the timezone incorrectly somewhere else or possibly that “America/Chicago (CDT)” is an old setting in your php.ini file from a previous version of PHP.

    Looking at the list of allowed timezone values from http://php.net/manual/en/timezones.america.php there is no “America/Chicago (CDT)” listed, so you should figure out where it’s getting set to that bogus value as it may cause other issues.

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

Sidebar

Related Questions

I'm encountering an odd problem showing .svg using simple img tags on Apache. On
I am encountering a problem while extracting info from a database using php+mysql and
I am encountering a problem which I have never encountered before. I am working
I'm encountering a very strange problem using g++ 4.1.2. I have a very basic
I'm encountering a huge problem, I have tried everything I could, but I didn't
I feel slightly like n00b encountering windows for the first time, but I have
I'm basically encountering the same problem as the poster in this question . My
I am encountering problems writing XML files using PHP. The following is my php
I am encountering a problem with passing data between pages that require facebook access.
I´m encountering this problem trying to mock some objects that receive complex lambda expressions

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.