Skip to content

Commit 8a080b2

Browse files
done
1 parent 1478dc2 commit 8a080b2

7 files changed

Lines changed: 1137 additions & 176 deletions

File tree

Solar_time.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
$latitude = 40.7128;
3+
$longitude = -74.0060;
4+
$timezoneOffset = -5;
5+
$dayOfYear = date('z') + 1;
6+
7+
function equationOfTime($dayOfYear) {
8+
$B = 2 * M_PI * ($dayOfYear - 81) / 364;
9+
return 9.87 * sin(2 * $B) - 7.53 * cos($B) - 1.5 * sin($B);
10+
}
11+
12+
function solarNoon($longitude, $timezoneOffset, $dayOfYear) {
13+
$EoT = equationOfTime($dayOfYear);
14+
return 12 + ($timezoneOffset - $longitude / 15) - $EoT / 60;
15+
}
16+
17+
$solarNoon = solarNoon($longitude, $timezoneOffset, $dayOfYear);
18+
19+
echo "Latitude: $latitude°\n";
20+
echo "Longitude: $longitude°\n";
21+
echo "Day of Year: $dayOfYear\n";
22+
echo "Local Solar Noon: " . gmdate("H:i", $solarNoon * 3600) . "\n";
23+
?>

age.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
date_default_timezone_set("Asia/Kolkata");
3+
4+
// Fixed birth date: 26 November 2005
5+
$birth = strtotime("2005-11-26 00:00:00");
6+
$now = time();
7+
8+
$seconds = $now - $birth;
9+
$minutes = floor($seconds / 60);
10+
$hours = floor($seconds / 3600);
11+
$days = floor($seconds / 86400);
12+
13+
echo "<h2>Age Calculator</h2>";
14+
15+
echo "<h3>Current Date & Time:</h3>";
16+
echo date("Y-m-d H:i:s", $now);
17+
18+
echo "<h3>Total Age Since 26 Nov 2005:</h3>";
19+
echo "Days: $days <br>";
20+
echo "Hours: $hours <br>";
21+
echo "Minutes: $minutes <br>";
22+
echo "Seconds: $seconds <br>";
23+
?>

location.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
// -------------------------------
3+
// 1. SET LATITUDE & LONGITUDE
4+
// -------------------------------
5+
6+
// You can change these values
7+
$latitude = 28.6139; // Example: Delhi
8+
$longitude = 77.2090;
9+
10+
11+
// -------------------------------
12+
// 2. SET TIMEZONE BASED ON LONGITUDE
13+
// -------------------------------
14+
// 360° = 24 hours
15+
// 15° = 1 hour
16+
17+
$timezoneOffset = round($longitude / 15);
18+
19+
// Create timezone name like UTC+5 or UTC-3
20+
if ($timezoneOffset >= 0) {
21+
$timezoneName = "Etc/GMT-" . $timezoneOffset;
22+
} else {
23+
$timezoneName = "Etc/GMT+" . abs($timezoneOffset);
24+
}
25+
26+
// Set timezone
27+
date_default_timezone_set($timezoneName);
28+
29+
30+
// -------------------------------
31+
// 3. GET CURRENT DATE & TIME
32+
// -------------------------------
33+
34+
$currentDate = date("Y-m-d");
35+
$currentTime = date("H:i:s");
36+
$dayName = date("l");
37+
38+
39+
// -------------------------------
40+
// 4. DISPLAY RESULTS
41+
// -------------------------------
42+
43+
echo "<h2>Location Information</h2>";
44+
echo "Latitude: " . $latitude . "<br>";
45+
echo "Longitude: " . $longitude . "<br><br>";
46+
47+
echo "<h3>Date & Time Details</h3>";
48+
echo "Timezone: " . $timezoneName . "<br>";
49+
echo "Current Date: " . $currentDate . "<br>";
50+
echo "Current Time: " . $currentTime . "<br>";
51+
echo "Day: " . $dayName . "<br>";
52+
53+
?>

0 commit comments

Comments
 (0)