Skip to content

Instantly share code, notes, and snippets.

@Mo3g4u
Last active December 15, 2016 09:07
Show Gist options
  • Save Mo3g4u/38b1ca19e76c8e33bb93f551eff7967a to your computer and use it in GitHub Desktop.
Save Mo3g4u/38b1ca19e76c8e33bb93f551eff7967a to your computer and use it in GitHub Desktop.
特定のフォーマットから日付を取り込んで、前の月の末日を取得
<?php
/**
* Created by PhpStorm.
* User: takeuchi
* Date: 2016/12/15
* Time: 17:58
*/
$date = DateTime::createFromFormat('Y年m月d日', '2017年06月11日');
$date->modify('-1 months');
echo $date->format('Y年m月t日');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment