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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:30:37+00:00 2026-05-28T08:30:37+00:00

Today is 24 gen 2012 for Europe. I’m using mktime to get a DateTime

  • 0

Today is 24 gen 2012 for Europe. I’m using mktime to get a DateTime object about today, midnight time. Why it says 23 o’clock of 23 gen, instead of 00:00 of 24 gen?

var_dump(new DateTime('@' . mktime(0, 0, 0)));

Output:

object(DateTime)[5]
  public 'date' => string '2012-01-23 23:00:00' (length=19)
  public 'timezone_type' => int 1
  public 'timezone' => string '+00:00' (length=6)
  • 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-28T08:30:38+00:00Added an answer on May 28, 2026 at 8:30 am

    mktime uses the local time zone information when deciding what the returned time should be and returns a value that is aligned to UTC. If you want to override this, then you need to pass in an explicit is_dst = 0 parameter

    You then use this UTC time when constructing the DateTime object (this is what the @ does), which means that the hour offset is replicated into the DateTime object.

    Because mktime uses the local timezone information, you should use the alternative gmmktime if you want to obtain midnight UTC using –

    $date = DateTime('@' . gmmktime(0, 0, 0));
    

    If you want midnight server time, and then to convert the output to a user’s timezone e.g. ‘Europe/Paris’ you would do the following:

    $date = DateTime('@' . mktime(0, 0, 0));
    $date->setTimeZone(new DateTimeZone('Europe/Paris'));
    print $date->format(DateTime::RFC850) . "\n";
    

    You can convert it to your server’s local time using:

    $date->setTimezone(new DateTimeZone(date_default_timezone_get()));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today i read about Joda time And they tells Calendar support. The library currently
Today, I ran into this weird problem with a user using Mac OS X.
Today I was listening to the Hanselminutes show about .NET 3.5 SP1...What's inside ,
Today I stumbled about a Problem which seems to be a bug in the
Today when I was in computer organization class, teacher talked about something interesting to
Today I had a discussion with a colleague about nested functions in Javascript: function
Today my question is how would I go about creating a view in a
Today, I have a problem with hosting my custom service host using custom binding
I've been using XML serialization for a while, and today I realized something really
Today EF4.3.1 released. http://blogs.msdn.com/b/adonet/archive/2012/02/29/ef4-3-1-and-ef5-beta-1-available-on-nuget.aspx . Follow the blog: http://thedatafarm.com/blog/data-access/using-ef-migrations-with-an-existing-database/ . I firstly run:add-migration initial

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.