Hi,
While working on a Web portal , I came across this simple problem.
I wanted to get current Time , and we use date() function to display this.
But it was showing wrong time , simply because we must set default time zone, and then we can try to use this date() function.
PHP Code :
//setting up timezone
date_default_timezone_set('Asia/Calcutta');
//use date() to display current time as follow
$curtime = date("H:i:s");
//Now you can use this variable to print true current date
?>
Ex. 12:2:00
To split above string into we use $split = explode(":",$curtime)
$split is now array containing values:
split[0] = 12
split[1] = 2
split[2] = 00
Best Regards,
Girish
No comments:
Post a Comment