Created
August 12, 2019 19:00
-
-
Save llagerlof/5ad52f410a7342a6584148bbfb97d053 to your computer and use it in GitHub Desktop.
One liner to identify a valid datetime "Y-m-d H:i:s" on PHP
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 | |
| /* | |
| This script can be used on terminal. Eg: | |
| $ php id_date_valid.php 2019-08-12 15:23:58 | |
| */ | |
| $datetime = $argv[1] . ' ' . $argv[2]; | |
| if ($datetime == date('Y-m-d H:i:s', strtotime ($datetime))) { | |
| echo "true"; | |
| } else { | |
| echo "false"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment