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