PHP 自作Class 日付取得
// =========================== 日付取得 クラス
class get_now_date {
function get_to_date() {
//====================== 現在時刻の取得
$n_year = "";
$n_month = "";
$n_day = "";
$n_hour = "";
$n_minute = "";
$n_second = "";
$now = new DateTime();
$now_tm = $now->format('Y-m-d H:i:s');
//======== 日付の - 空白 : を取る
$tt_0 = str_replace("-", "", $now_tm);
$ttt_0 = str_replace(":", "", $tt_0);
$now_tmp = str_replace(" ", "", $ttt_0);
// ======== 切り出し 年 月 日
$n_year = mb_substr($now_tmp, 0, 4);
$n_month = mb_substr($now_tmp, 4, 2);
$n_day = mb_substr($now_tmp, 6, 2);
// ======= 時間切り出し
$n_hour = mb_substr($now_tmp, 8, 2);
$n_minute = mb_substr($now_tmp, 10, 2);
$n_second = mb_substr($now_tmp, 12, 2);
return array (
'year' => $n_year,
'month' => $n_month,
'day' => $n_day,
'hour' => $n_hour,
'minute' => $n_minute,
'second' => $n_second
);
} //======= END Function
}; // ================== END class get_now_date