Posted at

PHPで日本語の曜日出す

More than 1 year has passed since last update.

なんやかんやで毎回使う

class Common {

static $WEEKS = ['(日)', '(月)', '(火)', '(水)', '(木)', '(金)', '(土)'];

function date($format, $timestamp=null) {
if ( preg_match('/x/', $format) ) {
$w = date('w', $timestamp);
$format = preg_replace('/x/', self::$WEEKS[$w], $format);
}
return date($format, $timestamp);
}
}

$Common = new Common();
$Common->date('Y年m月d日x H:i', strtotime('2017-03-17 12:00:00'));
// 2017年03月17日(金) 12:00

PHPで和暦・日本語曜日を使う