Page 1 of 1

retrieve current date

Posted: Fri Jan 09, 2009 10:25 am
by chxxangie

Code: Select all

 
$current_date   = date('Y-m-d');
$current_time   = date('G:i:s');
$current_time   = date('G:i:s', strtotime("+8 hours", strtotime($current_time))); 
 
now i can retrieve the current time. but how to retrieve the current date...?
thanks in advance...

Re: retrieve current date

Posted: Fri Jan 09, 2009 10:38 am
by mattpointblank
The first line of that code should give the current date...?

Re: retrieve current date

Posted: Fri Jan 09, 2009 10:56 am
by chxxangie
ok... like now in my country, the date is 2009-01-10.
but when i echo the first line, the date is 2009-01-09.
so how to make it when the time + 8 hours, the date will be auto adjusted to 2009-01-10...?

Re: retrieve current date

Posted: Fri Jan 09, 2009 11:11 am
by John Cartwright
Take a look at date_default_timezone_set for adjusting your timezone.

Re: retrieve current date

Posted: Fri Jan 09, 2009 11:19 am
by chxxangie
Jcart wrote:Take a look at date_default_timezone_set for adjusting your timezone.
it is works... thanks for helping....
this method is easier to echo the date and time... i even don't need to add 8 hours for the time.....