-1

I need to update jira custom field through API.

"customfield_10003": "2011-10-19T10:29:29.908+1100"

According to jira This format is ISO 8601: YYYY-MM-DDThh:mm:ss.sTZD

I need to create the same date format with PHP. Please help me to do so.

Vishnu Sharma
  • 632
  • 5
  • 19

2 Answers2

0

Use date with the c format.

http://php.net/manual/en/function.date.php

ISO 8601 date 2004-02-12T15:19:21+00:00

<?php
   echo date("c");

To convert a specific date, you use DateTime or strtotime and date.

Community
  • 1
  • 1
M.Alnashmi
  • 582
  • 1
  • 4
  • 15
0

Try this:

<?php

    $strDateAndTime = '2016-09-29 14:15:50';        
    $objDateTime    = new DateTime($strDateAndTime);
    $iso8601Date    = $objDateTime->format(DateTime::ATOM);
    var_dump($iso8601Date);   //<== string '2016-09-29T14:15:50+02:00' (length=25)
Poiz
  • 7,611
  • 2
  • 15
  • 17