LoginSignup
1
4

More than 5 years have passed since last update.

PHPで日本語の曜日出す

Posted at

なんやかんやで毎回使う

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で和暦・日本語曜日を使う

1
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4