dominic revised this gist . Go to revision
1 file changed, 37 insertions
date.php(file created)
@@ -0,0 +1,37 @@ | |||
1 | + | #!/usr/bin/env php | |
2 | + | <?php | |
3 | + | /* | |
4 | + | * PHP Skript zum Umrechnen von Datumsangaben (UNIX Timestamps) | |
5 | + | * Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com> | |
6 | + | * Last modified: Freitag, 02.11.2018 06:13 | |
7 | + | * Updated contact info on 2024-11-09 | |
8 | + | * | |
9 | + | */ | |
10 | + | ||
11 | + | /* | |
12 | + | * THIS SCRIPT IS FOR COMMAND LINE (CLI) ONLY!! | |
13 | + | * run with "php <script path & name> | |
14 | + | * php date.php [options] [args] | |
15 | + | * | |
16 | + | */ | |
17 | + | ||
18 | + | if ( isset ( $argv[1] ) ) { | |
19 | + | if ( !preg_match ( "/^[0-9]{10}$/", $argv[1] ) ) { | |
20 | + | die ( "Ungültiger Timestamp!\n" ); | |
21 | + | /* | |
22 | + | * TODO: delete this part, this is now implemented in regex above | |
23 | + | } elseif ( strlen ( trim ( $argv[1] ) ) != 10 ) { | |
24 | + | die ( "Ungültiger Timestamp!\n" ); | |
25 | + | */ | |
26 | + | }; | |
27 | + | ||
28 | + | echo " Timestamp: $argv[1]\n"; | |
29 | + | echo " Date: " . date ( "d.m.Y H:i:s", $argv[1] ); | |
30 | + | // echo "Actual Timestamp: " . time() . "\n"; | |
31 | + | // echo " Actual Date: " . date ( "d.m.Y H:i:s", time() ); | |
32 | + | } else { | |
33 | + | // Default: printing timestamp and calculate it to std date format (human readable) | |
34 | + | echo "Actual Timestamp: " . time() . "\n"; | |
35 | + | echo " Actual Date: " . date ( "d.m.Y H:i:s", time() ); | |
36 | + | }; | |
37 | + | ?> |
Newer
Older