Mihai Chiriac
Mihai Chiriac

Reputation: 143

getdate() returns wrong time

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

Answers (3)

deepika chavan
deepika chavan

Reputation: 11

Try adding date_default_timezone_set('Asia/Kolkata'); line before $today = getdate();

Upvotes: 1

CBusBus
CBusBus

Reputation: 2359

getDate()

"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

ale
ale

Reputation: 11820

Try date_timezone_set('some timezone') instead where 'some timezone' should be your desired zone.

Upvotes: 2

Related Questions