http://www.sharkpp.net/blog/2016/05/28/compare-format-for-date-to-string-php-and-ruby.html 用のスクリプト(PHP strftime() 関数)
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.strftime.php | |
foreach ([ | |
'%a', | |
'%A', | |
'%d', | |
'%e', | |
'%j', | |
'%u', | |
'%w', | |
'%U', | |
'%V', | |
'%W', | |
'%b', | |
'%B', | |
'%h', | |
'%m', | |
'%C', | |
'%g', | |
'%G', | |
'%y', | |
'%Y', | |
'%H', | |
'%k', | |
'%I', | |
'%l', | |
'%M', | |
'%p', | |
'%P', | |
'%r', | |
'%R', | |
'%S', | |
'%T', | |
'%X', | |
'%z', | |
'%Z', | |
'%c', | |
'%D', | |
'%F', | |
'%s', | |
'%x', | |
'%n', | |
'%t', | |
'%%', | |
// ほかの言語と同様に出力できるフォーマット | |
'%a, %d %b %Y %T %z', | |
] as $fmt) | |
{ | |
echo $fmt . '@@' . ('%P' == $fmt ? strtolower(strftime('%p', $timestamp)) : // ※ Mac OS X 用のfix | |
strftime($fmt, $timestamp)) . '@~'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment