Solved

Troubleshoot PHP date function?

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

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 108

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

Are your corporate email signatures appalling?

Is it scary how unprofessional your email signatures look? Do users create their own terrible designs and give themselves stupid job titles? You can make this a lot easier for yourself by choosing an email signature management solution from Exclaimer today.

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now