Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Troubleshoot PHP date function?

Posted on 2012-04-03
4
Medium Priority
?
555 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 84

Accepted Solution

by:
Dave Baldwin earned 400 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 400 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 400 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 400 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

670 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