Skip to content

Instantly share code, notes, and snippets.

@sharkpp
Last active May 28, 2016 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharkpp/0426f8dd6650083dc30768fc9f3f3c61 to your computer and use it in GitHub Desktop.
Save sharkpp/0426f8dd6650083dc30768fc9f3f3c61 to your computer and use it in GitHub Desktop.
<?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