Skip to content

Instantly share code, notes, and snippets.

@kylekatarnls
Created January 28, 2019 14:22
Show Gist options
  • Save kylekatarnls/a3bd1799acd138bf75597c973f936436 to your computer and use it in GitHub Desktop.
Save kylekatarnls/a3bd1799acd138bf75597c973f936436 to your computer and use it in GitHub Desktop.
<?php
$inputDateString = '2018-05-12 23:16:46.123456'; // get from DB or some API
$jsonFormat = 'Y-m-d\TH:i:s.u\Z';
$start = new DateTimeImmutable($inputDateString);
$end = $start->modify('+2 days');
echo json_encode([
'title' => 'Foobar',
'start' => $start->format($jsonFormat),
'end' => $end->format($jsonFormat),
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment