Solved

Troubleshoot PHP date function?

Posted on 2012-04-03
4
550 Views
Last Modified: 2012-04-12
I'm using a simple PHP snippet to display the current date and time, but it's showing tomorrow's date and time.

I verified that the server (Win Server 2008) the app (Drupal) is on has the correct date/time.

Where else should I check?
0
Comment
Question by:sandshakimi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 100 total points
ID: 37803189
What's the PHP snippet?  PHP sites normally use the server time unless you have set the timezone to something else.  Depending on where you are located (like hawaii), GMT may appear as tomorrow.  See if Drupal is using GMT for some reason.

http://us.php.net/manual/en/function.date.php
0
 
LVL 16

Assisted Solution

by:Wasim Akram Shaik
Wasim Akram Shaik earned 100 total points
ID: 37803204
I think, it because of the timezone which is causing the issue..

check the timezone which is set? you can simply retrieve the date from a different timezone..
0
 
LVL 12

Assisted Solution

by:junipllc
junipllc earned 100 total points
ID: 37803523
You're going to need something like this before your date() call:

date_default_timezone_set('America/Los_Angeles');

Open in new window


Here's the PHP manual page for that function...I hope it helps. At least there is a partial list of the possible arguments:

http://php.net/manual/en/function.date-default-timezone-set.php

Cheers,

Mike
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 100 total points
ID: 37810369
You can detect the timezone setting in effect on your server.
http://us3.php.net/manual/en/function.date-default-timezone-get.php

You can also find this information in the middle of the output from this script (shown in its entirety): <?php phpinfo();

This article might be helpful as you plan your work with Date and Time information.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A safe way to clean winsxs folder from your windows server 2008 R2 editions
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question