Solved

Troubleshoot PHP date function?

Posted on 2012-04-03
4
540 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
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

713 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