Skip to content

Instantly share code, notes, and snippets.

@sharkpp
Last active May 28, 2016 13:39
Embed
What would you like to do?
<?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