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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:30:14+00:00 2026-06-04T22:30:14+00:00

I used date(Y-m-d H:i:s); to get current date time format but the result doesn’t

  • 0

I used date("Y-m-d H:i:s"); to get current date time format but the result doesn’t match with my Windows system.

Example:

<?php
echo "Current date time: ".date("Y-m-d H:i:s")."<br />";
?>

The sample code displaying result:

Current date time: 2012-05-30 01:58:21

But my Windows system date time is 2012-05-30 09:56:04

I have tried using date_default_timezone_set('Asia/Singapore') function to get my region datetime and it’s work but I want it set default in my php.ini.

For example: (it’s work)

<?php
date_default_timezone_set('Asia/Singapore');
echo "Current date time: ".date("Y-m-d H:i:s")."<br />";
?>

I have also tried to set default value in php.ini that is date.timezone = "" changed to date.timezone = "Asia/Singapore" but doesn’t work.

I use Windows 7 Home Premium 64bit and php-5.3.13-Win32-VC9-x86. Does anyone know how to match between these value?

  • 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-04T22:30:15+00:00Added an answer on June 4, 2026 at 10:30 pm

    date_default_timezone_set will supersede php default timezone setting, without needing to restart anything.
    But in your case it did not work. that’s weird. Try this as this is my last resort:

    <?php
    header('Content-Type: text/plain');
    //date_default_timezone_set('Asia/Singapore');
    date_default_timezone_set('Etc/GMT+8');
    echo date("Y-m-d H:i:s A T", time());
    ?>
    

    UPDATES:

    Since what you need is a default php timezone and permanent solution without using date_default_timezone_set, following the few simple steps below:

    1. Create a file called phpinfo.php with one line content <?php echo phpinfo(); ?>
    2. Run http:// localhost /phpinfo.php and look for Loaded Configuration File. Example value C:\wamp\bin\apache\Apache2.2\bin\php.ini
    3. Open the above php.ini file with a notepad. Look for the [Date] and modify as below:

      [Date]
      ; Defines the default timezone used by the date functions
      ; http://php.net/date.timezone
      date.timezone = Asia/Singapore
      
    4. Save it and restart your apache. Run again your datetime.php. Or you can also verify directly from phpinfo.php under a h1 header date by making sure the default timezone is read as “Asia/Singapore” like below:
      enter image description here
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've used the localtime function in Perl to get the current date and time
I've used Date Format 1.2.3 to format my time into yyyy-mm-dd hh:MM:ss and used
I used SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy, HH:mm"); String time = formatter.format(new Date()); to
I used Date() for getting the date of my birthday, but it was returned
I have a java program where I used java.util.Date to fetch current date and
Does anybody know which date format is to be used, trying to create a
is there any easy to validate a time field entry against the current date
I have asked aqbout timezones and date/time before but this is a more specific
Continuing from Stack Overflow question Java program to get the current date without timestamp
I have current have two UI components used to specify a date and a

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.