【发布时间】:2015-11-19 14:33:13
【问题描述】:
我正在创建一个每周工作的表格日历。日历是这样的
我使用找到的代码here 来设置我的标题日期。我的代码如下所示:
$dt = new DateTime;
$dt->setISODate($dt->format('o'), $dt->format('W'));
$year = $dt->format('o');
$week = $dt->format('W');
$current_time = time();
$return .= '<table class="reservation_time_table">
<tr><th>'.esc_html__('Hours', 'time_reservation').'</th>';
do {
$return .= '<th>' . $dt->format('l') . '<br>' . $dt->format('d M Y') . '</th>';
$dt->modify('+1 day');
} while ($week == $dt->format('W'));
$return .= '</tr>';
for ($hour=8; $hour < 23 ; $hour++) {
$return .= '<tr>';
$return .= '<th>'.$hour.':00</th>';
for ($i=0; $i <7 ; $i++) {
$return .= '<td data-reservation_time=""></td>';
}
$return .= '</tr>';
}
$return .= '</table>';
现在,我需要以Unix 格式输入我的data-reservation_time 日期(这就是为什么有$current_time 变量),该单元格。因此,例如,在 20 日星期五 8:00 的单元格中,该单元格中应该有 1448006400。稍后我将使用它来存储在数据库中。
但是我该怎么做呢?我被困在这一点上。任何帮助表示赞赏。
编辑
找到了答案。它在下面:)
【问题讨论】: