-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalendar.php
70 lines (59 loc) · 1.84 KB
/
calendar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
// Set timezone to your preference
date_default_timezone_set('America/New_York');
$currentDateTime = date("Y-m-d H:i:s");
// Get current date information
$currentYear = date("Y");
$currentMonth = date("m");
$currentDay = date("d");
// Get the first day of the current month
$firstDayOfMonth = mktime(0, 0, 0, $currentMonth, 1, $currentYear);
// Get the number of days in the current month
$numberOfDaysInMonth = date("t", $firstDayOfMonth);
// Get the name of the current month
$monthName = date("F", $firstDayOfMonth);
// Get the index of the first day of the week for the current month
$dayOfWeek = date("N", $firstDayOfMonth);
// Start the HTML output
echo "Current date and time in New York: $currentDateTime";
echo "<h2>$monthName $currentYear</h2>";
echo "<table border='1'>";
echo "<tr><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th><th>Sun</th></tr>";
// Start counting the days
$dayCount = 1;
// Create the calendar rows
for ($i = 0; $i < 6; $i++) {
echo "<tr>";
for ($j = 0; $j < 7; $j++) {
if (($i == 0 && $j < $dayOfWeek - 1) || ($dayCount > $numberOfDaysInMonth)) {
echo "<td></td>";
} else {
if ($dayCount == $currentDay) {
echo "<td style='background-color: #ffff00;'>$dayCount</td>";
} else {
echo "<td>$dayCount</td>";
}
$dayCount++;
}
}
echo "</tr>";
}
// Close the table
echo "</table>";
?>
<!DOCTYPE html>
<html>
<head>
<style>
</style>
<link rel="stylesheet" type="text/css" href="./Calendar.css">
</head>
<body>
<button class="next-button" onclick = "goToHome()">back to home page</button>
<script>
function goToHome() {
window.location.href = "welcome.php";
}
</script>
</body>
</html>