Created
January 22, 2019 13:47
-
-
Save ivuorinen/f90c25fd85b042cd209ae41e03d988f3 to your computer and use it in GitHub Desktop.
From 20190122-124559 to 2019-01-22 12:45:59 with preg_replace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// From 20190122-124559 to 2019-01-22 12:45:59 | |
$patterns = '/(19|20)(\d{2})(\d{1,2})(\d{1,2})-(\d{1,2})(\d{1,2})(\d{1,2})/'; | |
$replace = '\1\2-\3-\4 \5:\6:\7'; | |
$date = preg_replace($patterns, $replace, $date); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment