1 <html>
2 <head>
3 <title>Konwerter stref czasowych</title>
4 </head>
5 <body>
6 <?php
7 // Tablica przechowujca cigi tekstowe standardowych stref czasowych.
8 $time_zones = array("Asia/Hong_Kong",
9 "Africa/Cairo",
10 "Europe/Paris",
11 "Europe/Madrid",
12 "Europe/London",
13 "Asia/Tokyo",
14 "America/New_York",
15 "America/Los_Angeles",
16 "America/Chicago");
17 // Sprawdzenie, czy formularz zosta wysany.
18 if ($_GET["start_time"] != NULL){
19 $start_time_input = $_GET["start_time"];
20 $start_tz = $_GET["start_tz"];
21 $end_tz = $_GET["end_tz"];
22 putenv("TZ=$start_tz");
23 $start_time = strtotime($start_time_input);
24 echo "<p><strong>";
25 echo date("h:i:sA",$start_time)."\n";
26 echo "</strong>";
27 putenv("TZ=$end_tz");
28
29 echo "w $start_tz odpowiada ";
30 echo "<strong> ";
31 echo date("h:i:sA",$start_time)."\n";
32 echo "</strong>";
33 echo " w $end_tz.</p><hr />";
34}
35 ?>
36 <form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="GET">
37 <label>
38 Twj czas:
39 <input type="text" name="start_time" value="<?php echo $start_time_input; ?>" />
40 </label> w
41 <select name="start_tz">
42 <?php
43 foreach ($time_zones as $tz) {
44 echo '<option';
45 if (strcmp($tz, $start_tz) == 0){
46 echo ' selected="selected"';
47 }
48 echo ">$tz</option>";
49}
50 ?>
51 </select>
52 <p>Konwersja na:
53 <select name="end_tz">
54 <?php
55 foreach ($time_zones as $tz) {
56 echo '<option';
57 if (strcmp($tz, $end_tz) == 0){
58 echo ' selected="selected"';
59 }
60 echo ">$tz</option>";
61 }
62
63 ?>
64 </select></p>
65 <input type="submit" value="Konwertuj!" />
66 </form>
67 </body>
68 </html>
