如何从 php 中的年、月、月中的星期和星期中的日期获取日期
How to get the date from year, month, week of the month, and day of the week in php
我有年、月、月中的星期和星期中的日期。我想约会。
例如:
$year = 2019;
$month = 8;
$week = 2; // second week of the month
$day = 2; // tuesday
$date = getDate($year, $month, $week, $day); // $date = '06/08/2019'
你可以试试PHP Relative Formats.
像这样
$date = new DateTime('first day of August 2019');
$date->modify('tuesday next week');
echo $date->format('Y-m-d');
它需要一点点从数字到字符串的转换,但是当您需要处理相对日期时它很有用。
我有年、月、月中的星期和星期中的日期。我想约会。 例如:
$year = 2019;
$month = 8;
$week = 2; // second week of the month
$day = 2; // tuesday
$date = getDate($year, $month, $week, $day); // $date = '06/08/2019'
你可以试试PHP Relative Formats.
像这样
$date = new DateTime('first day of August 2019');
$date->modify('tuesday next week');
echo $date->format('Y-m-d');
它需要一点点从数字到字符串的转换,但是当您需要处理相对日期时它很有用。