Created
October 3, 2011 17:28
-
-
Save aaronpk/1259678 to your computer and use it in GitHub Desktop.
Loqi's date command
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 | |
| $error[] = 'Sorry, I couldn\'t parse that'; | |
| $error[] = 'That doesn\'t look like a date'; | |
| $error[] = 'Hmm, no clue'; | |
| $error[] = 'What?'; | |
| $error[] = 'Sorry.'; | |
| $error[] = 'I give up'; | |
| $success[] = 'That looks like a unix timestamp!'; | |
| $success[] = 'That looks like a unix timestamp!'; | |
| $success[] = 'That looks like a unix timestamp!'; | |
| $success[] = 'Nom nom nom!'; | |
| $success[] = $message . ' is a unix timestamp!'; | |
| if(trim($message) != '') { | |
| $message = trim($message); | |
| if(is_numeric($message) && strlen($message) == 10) { | |
| echo $success[rand(0,count($success)-1)] . ' ' . date('Y-m-d H:i:s T', $message); | |
| } else { | |
| $date = strtotime($message); | |
| if($date) | |
| echo $message . ' is ' . date('Y-m-d H:i:s T', $date) . ' (' . $date . ')'; | |
| else | |
| echo $error[rand(0,count($error)-1)]; | |
| } | |
| } else { | |
| echo 'It is ' . date('Y-m-d H:i:s T') . ' or ' . time() . ' in unixtime'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment