Vitek
Vitek

Reputation:

How can i use PHP to show datetime without seconds

How can i change ex. 2009-01-14 06:38:18 to 2009-01-14 06:38? the column type is DATETIME. i dont wanna use SELECT DATE_FORMAT

How could I do it with PHP? date("M-d-Y H:i", $userow['regdate']) gives:

Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set()

Upvotes: 0

Views: 860

Answers (2)

gnrfan
gnrfan

Reputation: 19391

The error message just suggest you specify your timezone so you end up printing the correct date for your intended audience. Other than that, date() expects a timestamp as it's second argument so that's why converting the string MySQL returned to an int with strtotime() definitely helps.

Upvotes: 0

Karsten
Karsten

Reputation: 14642

Use date_default_timezone_set() before, as your error says.

Upvotes: 3

Related Questions