-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDayOfTheWeek.php
More file actions
48 lines (41 loc) · 914 Bytes
/
DayOfTheWeek.php
File metadata and controls
48 lines (41 loc) · 914 Bytes
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
<?php # https://leetcode.com/problems/day-of-the-week/
/**
* @param Integer $day
* @param Integer $month
* @param Integer $year
* @return String
*/
function dayOfTheWeek($day, $month, $year) {
if ($day < 10 ) {
$day = "0$day";
}
if ($month < 10 ) {
$month = "0$month";
}
return getdate(strtotime("$day-$month-$year"))['weekday'];
}
if ( dayOfTheWeek(31,8,2019) == "Saturday" ) {
echo "correcto<br>";
}else{
echo "incorrecto<br>";
}
if ( dayOfTheWeek(18,7,1999) == "Sunday" ) {
echo "correcto<br>";
}else{
echo "incorrecto<br>";
}
if ( dayOfTheWeek(15,8,1993) == "Sunday" ) {
echo "correcto<br>";
}else{
echo "incorrecto<br>";
}
if ( dayOfTheWeek(4,7,2020) == "Saturday" ) {
echo "correcto<br>";
}else{
echo "incorrecto<br>";
}
if ( dayOfTheWeek(6,7,2020) == "Monday" ) {
echo "correcto<br>";
}else{
echo "incorrecto<br>";
}