php date() function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
heshan
Forum Commoner
Posts: 26
Joined: Tue Jul 13, 2010 1:16 pm

php date() function

Post by heshan »

Hi all,

This is the code that displays current date and time according to the GMT time.
How can i convert it to the local date and time?

Code: Select all

<?php
$today = date("d M Y h:i A"); 
echo $today 
?>

Thanks,
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: php date() function

Post by AbraCadaver »

date() is using the local timezone for the server that it is running on. If you want a different timezone:

Code: Select all

date_default_timezone_set()
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: php date() function

Post by klevis miho »

This is what I needed too. I got the time from the server and added or substracted seconds from it, to fit my timezone.
Thnx AbraCadaver
Post Reply