Created
April 14, 2016 15:04
-
-
Save jimmycann/9d767450c23a0d85dbcb77edc3cbda3d to your computer and use it in GitHub Desktop.
Convert Custom Date with PHP
This file contains 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 | |
$depart = "140117"; | |
$arrive = "arriving on 21 January 2017"; | |
$dep_date = DateTime::createFromFormat('dmy', $depart); | |
$arr_date = DateTime::createFromFormat('\a\r\r\i\v\i\n\g \o\n d F Y', $arrive); | |
$date_diff = $dep_date->diff($arr_date); | |
$dep_date = $dep_date->format('d-m-Y'); | |
$arr_date = $arr_date->format('m/d/Y'); | |
echo "The difference between ". $dep_date ." and ". $arr_date ." is ". $date_diff->d ." days."; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment