I sent the following string to Marketo REST API to be set as the value of a datetime
field:
"2010-05-07T15:41:32"
But Marketo displays it as:
May 6, 2010 8:00 PM
Is there something i'm missing?
It is always a bit tricky to deal with DateTime
properly.
Most probably there are two, but related issues here:
Luckily, you can easily overcome this issue.
The exact format for the datetime string should follow the ISO 8601 standard, as it is described in the Field Types section of the documentation. An important part of that specification is the timezone offset, which follows the “normal” datetime part as the difference to Greenwich time in the form of ±hh:mm
. So, depending on your timezone, your date string should look like somthing like this: 2017-05-08T08:08:08+02:00
. (Where +02:00
is for Central Europe.)
In case you are using PHP, the easiest way to have this format is by using the c
full Date/Time format, like so:
$date = new DateTime('2010-05-07 15:41:32', new DateTimeZone('Europe/Budapest'));
$dateString = $date->format('c');
var_dump($dateString);
// outputs: '2017-05-08T08:08:08+02:00'