简体   繁体   中英

Separated by years, months, days of the date

how can separate year, month, day in date. and each put in variable?

1390/02/05
$year = '1390';
$month = '02';
$day = '05';

With respect

Something like:

list($year, $month, $day) = explode('/', '1390/02/05', 3);
$timestamp = strtotime('1390/02/05');
$year = date('Y', $timestamp);
$month = date('m', $timestamp);
$day = date('d', $timestamp);

you could do:

$date = '1390/02/05';
$array = $explode('/', $date);

$year = $array[0];
$month = $array[1];
$day = $array[2];
list($year, $month, $day) = explode('/', '1390/02/09', 3);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM