I'm creating a table calendar, that works on the weekly basis. The calendar looks like this
I used code I found here to set up my header dates. The code I have looks like this:
$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>';
Now, I need to put in my data-reservation_time
the date in Unix
format (that's why there is $current_time
variable), of that cell. So for instance in the cell for Friday 20 in 8:00 there should be 1448006400
in that cell. I'll use this later on to store in the database.
But how do I do that? I'm stuck at this point. Any help is appreciated.
EDIT
Found the answer. It's below :)