LoginSignup
1
2

More than 5 years have passed since last update.

MySQLとPHPの週番号の日付フォーマット。

Posted at

週番号

  • 2017年1月1日は日曜日なので「月曜始まり」or「日曜始まり」で週番号が変わる

スクリーンショット 2017-05-22 11.06.09.png

MySQL

  • MySQLのマニュアルには日曜始まり、月曜始まりがある。
select 
    date_format('2017-01-01', '%X%V') as nichiyou_start, -- 201701 
    date_format('2017-01-01', '%x%v') as getsuyou_start; -- 201652

PHP

  • PHPのマニュアルには月曜始まりしかない
$this->assertEquals('201652', \Carbon\Carbon::parse('2017-01-01')->format('oW'));

参考

1
2
0

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
2