1. Home
  2. Computing & Technology
  3. PHP / MySQL
photo of Angela Bradley
Angela's PHP / MySQL Blog

By Angela Bradley, About.com Guide to PHP / MySQL

Showing the Current Date

Monday September 10, 2007
Displaying the current date on your website is as simple as one line of code. It uses both the print and date functions to generate today's date on your website.
Comments
September 10, 2007 at 8:25 pm
(1) Jody says:

Regarding your PHP Cookie tutorial at
http://php.about.com/od/advancedphp/qt/php_cookie.htm

The tutorial works but shows the server time. How do I offset the time for my time zone? I am central and my server time is an hour ahead of me.

Thanks.

September 11, 2007 at 9:58 am
(2) php says:

http://us.php.net/date

See the Z option

September 12, 2007 at 7:20 am
(3) Jody says:

I just can’t get it to work. I have visited http://us.php.net/date before and did it again just now to see if I could make heads or tails of it. No go.

This is what I am getting from the cookie:
Welcome back! You last visited on September 12th, 2007 @ 7:14 AM

However, the time right now should be 6:14 AM because I am in a different time zone than my server.

What do I put in this following code of yours to offset the time back an hour from the server time:

?php
$Month = 31536000 + time() ;
//this adds 365 days to the current time
setcookie(JodySite1, date(”F jS, Y @ g:i A”), $Month);
?

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL

©2009 About.com, a part of The New York Times Company.

All rights reserved.