Skip to content

Instantly share code, notes, and snippets.

@gouf
Created April 28, 2016 08:25
Show Gist options
  • Select an option

  • Save gouf/a03beacaf2e797419885a7c3957df4c9 to your computer and use it in GitHub Desktop.

Select an option

Save gouf/a03beacaf2e797419885a7c3957df4c9 to your computer and use it in GitHub Desktop.
正規表現とlist 関数による多重代入で、日付と時刻を扱いやすい形に変換する
<?php
$now = date("Y-m-d H:i:s");
list($_year, $month, $day, $hour, $min, $sec) = preg_split('/[-: ]/', $now);
echo "${month}月${day}日"; // => 04月28日
echo "${hour}:${min}:${sec}"; // => 08:20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment