Reputation: 143
Server hour using "date" via shell (linux server) returns 17:00 , time()
in a php file returns 17:00 , getdate()
in the same php file returns 11:00.
I tried date_default_timezone_set('')
with different timezones but getdate()
returns the current real hour minus 6 hours.
Someone have any idea on why this happens and/or how can i fix this ?
Thank you.
Upvotes: 0
Views: 785
Reputation: 11
Try adding date_default_timezone_set('Asia/Kolkata');
line before $today = getdate();
Upvotes: 1
Reputation: 2359
"Returns an associative array containing the date information of the timestamp, or the current local time if no timestamp is given."
You could use something like this.
$date = date("Date-For-mat", time());
splitting the $date value by the format delimiter if you need it in array form.
Upvotes: 0
Reputation: 11820
Try date_timezone_set('some timezone')
instead where 'some timezone' should be your desired zone.
Upvotes: 2