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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:19:11+00:00 2026-05-25T23:19:11+00:00

I am writing a function to convert an internal date format into a timestamp

  • 0

I am writing a function to convert an internal date format into a timestamp value. However, when I print the date out in YYYY-MM-DD HH format the date is 12 hours off.

The code below gives me the wrong date and time. I am expecting 2011-03-25 13 but instead I am getting 2011-03-25 01.

 date_default_timezone_set("Europe/London");
 $epoch = mktime(13,0,0,3,25,2011);
 echo date('Y-m-d h', $epoch);

When I use the following code I expect 2001-02-01 01 and get what I expected.

 date_default_timezone_set("Europe/London");
 $epoch = mktime(1,0,0,2,1,2011);
 echo date('Y-m-d h', $epoch);

It seems that the 12 hour offset starts on March 25th in the 13th hour.

Any idea why this happens and how do I keep it from happening? Does this have to do with the different day light savings dates? The server timezone is set to “America/Los_Angeles”.

  • 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-25T23:19:11+00:00Added an answer on May 25, 2026 at 11:19 pm

    It works, you’re just using the wrong format code, take H (24 hour format) instead of h (12 hour format):

    date_default_timezone_set("Europe/London");
    $epoch = mktime(13,0,0,3,25,2011);
    echo date('Y-m-d H', $epoch);
    

    Read the PHP Manual, it explains each code in detail.

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

Sidebar

Related Questions

I'm writing a function to convert MS Word-styled text into Adobe InDesign-formatted text (it
I'm writing a function to take shorthand values and convert them into a standardized
Let's say that I'm writing a function to convert between temperature scales. I want
I'm currently writing a helper function in VB.NET to convert an array of enum
I'm writing a function that fishes out the src from the first image tag
I am writing an iPhone application, which contains a function. It can convert the
Has anyone got a function to convert convert curly quotes and em dashes into
I'm writing a Bison/Flex program to convert LaTeX into MathML. At the moment, dealing
I am writing this code. Here dt is input into the function, as well
I'm writing a function like this: Private Function mostRecent(ByVal folder As Directory) As Date

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.