Created
May 28, 2016 09:46
-
-
Save sharkpp/84deb455f9e1ffbc50f8cf1d5a0c399b to your computer and use it in GitHub Desktop.
http://www.sharkpp.net/blog/2016/05/28/compare-format-for-date-to-string-php-and-ruby.html 用のスクリプト(PHP date() 関数)
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 | |
// The MIT License (MIT) | |
// Copyright (c) 2016 sharkpp. | |
// See: https://opensource.org/licenses/mit-license.php | |
ini_set('date.timezone', 'Asia/Tokyo'); | |
$timestamp = isset($argv[1]) ? (int)$argv[1] : mktime(23, 45, 58, 2, 29, 2004); | |
// http://jp2.php.net/manual/ja/function.date.php | |
foreach ([ | |
'd', | |
'D', | |
'j', | |
'l', | |
'N', | |
'S', | |
'w', | |
'z', | |
'W', | |
'F', | |
'm', | |
'M', | |
'n', | |
't', | |
'L', | |
'o', | |
'Y', | |
'y', | |
'a', | |
'A', | |
'B', | |
'g', | |
'G', | |
'h', | |
'H', | |
'i', | |
's', | |
'u', | |
'e', | |
'I', | |
'O', | |
'P', | |
'T', | |
'Z', | |
'c', | |
'r', | |
'U', | |
] as $fmt) | |
{ | |
// $d = new DateTime($timestamp); echo $fmt . '@@' . $d->format($fmt) . '@~'; unset($d); | |
echo $fmt . '@@' . date($fmt, $timestamp) . '@~'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment