Skip to content

Instantly share code, notes, and snippets.

@Songmu
Last active December 24, 2019 10:19
Show Gist options
  • Save Songmu/5f6960765ae618dfdfb76e9c2406d7af to your computer and use it in GitHub Desktop.
Save Songmu/5f6960765ae618dfdfb76e9c2406d7af to your computer and use it in GitHub Desktop.
<?php
$date_str = '2017-07-25T15:26:16.12+02:00';
$date_str = preg_replace('/^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})(?:(\\.\\d{6})\\d*)?(.*)/', '$1$2$3', $date_str);
$d = DateTime::createFromFormat("Y-m-d\TH:i:s.uP", $date_str);
var_dump($d);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment