经过一个多小时的挣扎和尝试,我想在这里问一下。
尝试在PHP中用周等方式制作一些东西我从你的网站得到了这个: Get all Work Days in a Week for a given date
很好,对我很好。
但是......我无法获取,尝试和尝试这部分数据:[date] => 2013-08-12 00:00:00
Array
(
[0] => DateTime Object
(
[date] => 2013-08-12 00:00:00
[timezone_type] => 3
[timezone] => Europe/Amsterdam
)
如何从阵列中获取该日期? 请帮助我,提前感谢您的帮助!
答案 0 :(得分:0)
$dateTime = new DateTime('2013-08-12 00:00:00');
echo $datetime->format('Y-m-d'); // produces 2013-08-12
答案 1 :(得分:0)
$firstMondayThisWeek= new DateTime('2013-08-12');
$firstMondayThisWeek->modify('tomorrow');
$firstMondayThisWeek->modify('last Monday');
$nextFiveWeekDays = new DatePeriod(
$firstMondayThisWeek,
DateInterval::createFromDateString('+1 weekdays'),
4
);
$dateTimes = iterator_to_array($nextFiveWeekDays);
foreach ($dateTimes as $dateTime) {
echo $dateTime->format('Y-m-d H:i:s');
}