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
Solved

Troubleshoot PHP date function?

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

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

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…
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

789 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