date.php
· 1.1 KiB · PHP
Raw
#!/usr/bin/env php
<?php
/*
* PHP Skript zum Umrechnen von Datumsangaben (UNIX Timestamps)
* Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com>
* Last modified: Freitag, 02.11.2018 06:13
* Updated contact info on 2024-11-09
*
*/
/*
* THIS SCRIPT IS FOR COMMAND LINE (CLI) ONLY!!
* run with "php <script path & name>
* php date.php [options] [args]
*
*/
if ( isset ( $argv[1] ) ) {
if ( !preg_match ( "/^[0-9]{10}$/", $argv[1] ) ) {
die ( "Ungültiger Timestamp!\n" );
/*
* TODO: delete this part, this is now implemented in regex above
} elseif ( strlen ( trim ( $argv[1] ) ) != 10 ) {
die ( "Ungültiger Timestamp!\n" );
*/
};
echo " Timestamp: $argv[1]\n";
echo " Date: " . date ( "d.m.Y H:i:s", $argv[1] );
// echo "Actual Timestamp: " . time() . "\n";
// echo " Actual Date: " . date ( "d.m.Y H:i:s", time() );
} else {
// Default: printing timestamp and calculate it to std date format (human readable)
echo "Actual Timestamp: " . time() . "\n";
echo " Actual Date: " . date ( "d.m.Y H:i:s", time() );
};
?>
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 | ?> |
38 |