-3

I want to convert dates in following format using php...

2014-12-09T18:30:00.000Z

What do we call this type of time format?

How to format any date to this format?

Please suggest, thanks

seoppc
  • 2,766
  • 7
  • 44
  • 76
  • Take a look at [`DateTime::createFromFormat1`](http://php.net/manual/en/datetime.createfromformat.php) or [`date()`](http://php.net/date) – scrowler Dec 09 '14 at 09:22
  • 1
    possible duplicate of [How to format an UTC date to use the Z (Zulu) zone designator in php?](http://stackoverflow.com/questions/17390784/how-to-format-an-utc-date-to-use-the-z-zulu-zone-designator-in-php) – machineaddict Dec 09 '14 at 09:22
  • @scrowler I know how to format dates, i want to know what do we call this format? How to convert any date into this format? – seoppc Dec 09 '14 at 09:23
  • Check the documentation of [`date()`](http://my1.php.net/manual/en/function.date.php)/[`gmdate()`](http://my1.php.net/manual/en/function.gmdate.php), [`strftime()`](http://my1.php.net/manual/en/function.strftime.php) and [`DateTime::format()`](http://my1.php.net/manual/en/datetime.format.php) – axiac Dec 09 '14 at 09:24
  • @machineaddict thanks for your help, i got it solved by referred question. – seoppc Dec 09 '14 at 09:24

1 Answers1

0

I think this is what you want :

$date->format('Y-m-d\TH:i:s\Z');

EDIT :

Time Zones

To specify a time zone, you can either enter a date in UTC time by adding a "Z" behind the date - like this:

2002-09-24Z

DateTime Data Type

The dateTime data type is used to specify a date and a time.

The dateTime is specified in the following form "YYYY-MM-DDThh:mm:ss" where:

YYYY indicates the year
MM indicates the month
DD indicates the day
T indicates the start of the required time section
hh indicates the hour
mm indicates the minute
ss indicates the second
Buisson
  • 479
  • 1
  • 6
  • 23