How to get GMT date in yyyy-mm-dd hh:mm:ss in PHP

Asked
Active3 hr before
Viewed126 times

6 Answers

90%

I want to get the current date in yyyy-mm-dd hh:mm:ss format.,gmdate('yyyy-mm-dd hh:mm:ss \G\M\T', time());, Meta Stack Overflow ,Its returning a wierd date:

You don't have to repeat those format identifiers . For yyyy you just need to have Y, etc.

gmdate('Y-m-d h:i:s \G\M\T', time());

In fact you don't even need to give it a default time if you want current time

gmdate('Y-m-d h:i:s \G\M\T'); // This is fine for your purpose
load more v
88%

Its returning a wierd date:,I want to get the current date in yyyy-mm-dd hh:mm:ss format.,gmdate('yyyy-mm-dd hh:mm:ss \G\M\T', time());,Use below date function to get current time in MySQL format/(As requested on question also)

You don't have to repeat those format identifiers . For yyyy you just need to have Y, etc.

gmdate('Y-m-d h:i:s \G\M\T', time());

In fact you don't even need to give it a default time if you want current time

gmdate('Y-m-d h:i:s \G\M\T'); // This is fine for your purpose
load more v
72%

The format of the outputted date string. See the formatting options for the date() function. ,strftime() - Format a local time/date according to locale settings, The optional timestamp parameter is an int Unix timestamp that defaults to the current local time if timestamp is omitted or null. In other words, it defaults to the value of time(). , Returns a formatted date string.

load more v
65%

date("d/m/Y", strtotime($str));
load more v
75%

I want to get the current date in yyyy-mm-dd hh:mm:ss format.,gmdate('yyyy-mm-dd hh:mm:ss GMT', time());,Its returning a wierd date:,Use the PHP date function to reformat it:

You don't have to repeat those format identifiers . For yyyy you just need to have Y, etc.

gmdate('Y-m-d h:i:s GMT', time());

In fact you don't even need to give it a default time if you want current time

gmdate('Y-m-d h:i:s GMT'); // This is fine for your purpose
load more v
40%

I want to get the current date in yyyy-mm-dd hh:mm:ss format.,You don't have to repeat those format identifiers . For yyyy you just need to have Y, etc.,gmdate('yyyy-mm-dd hh:mm:ss GMT', time());,Its returning a wierd date:

You don't have to repeat those format identifiers . For yyyy you just need to have Y, etc.

gmdate('Y-m-d h:i:s GMT', time());
load more v

Other "undefined-undefined" queries related to "How to get GMT date in yyyy-mm-dd hh:mm:ss in PHP"