Untitled diff

Created Diff never expires
18 removals
58 lines
23 additions
63 lines
<?php
<?php
$timezones = array(
$timezones = array(
'EST' => -5*3600, //equador
'EST' => -5*3600, //equador
'UTC' => 0, //london
'UTC' => 0, //london
'CCT' => +8*3600, //beijing
'CCT' => +8*3600, //beijing
'PST' => -8*3600, //los angeles
'PST' => -8*3600, //los angeles
);
);
foreach ($timezones as $time) {
foreach ($timezones as $time) {
$now = time();
$now = time();
$now += $time;
$now += $time;
print gmstrftime('DATE: %B %d %Y and TIME: %r <br/>',$now);
print gmstrftime('DATE: %B %d %Y and TIME: %r <br/>',$now);
}
}
$nowM = date('m');
$nowM = date('m');
$nowD = date('d');
$nowD = date('d');
$nowY = date('Y');
$nowY = date('Y');
$nowHr = date('h');
$nowHr = date('h');
$nowMin = date('i');
$nowMin = date('i');
$nowSec = date('s');
$nowSec = date('s');
?>
?>
<form action="homework2.php" method="post">
<form action="homework2.php" method="post">
<label>Sync Timecode</label>
<label>Sync Timecode</label>
<input type="text" name="month" placeholder="Month <?php $nowM ?>" value="<?php $nowM ?>" />
<input type="text" name="month" placeholder="Month <?php $nowM ?>" value="<?php $nowM ?>" />
<input type="text" name="day" placeholder="Day <?php $nowD ?>" value="<?php $nowD ?>" />
<input type="text" name="day" placeholder="Day <?php $nowD ?>" value="<?php $nowD ?>" />
<input type="text" name="year" placeholder="Year <?php $nowY ?>" value="<?php $nowY ?>" />
<input type="text" name="year" placeholder="Year <?php $nowY ?>" value="<?php $nowY ?>" />
<input type="text" name="hour" placeholder="Hours <?php $nowHr ?>" value="<?php $nowHr ?>" />
<input type="text" name="hour" placeholder="Hours <?php $nowHr ?>" value="<?php $nowHr ?>" />
<input type="text" name="min" placeholder="Minutes <?php $nowMin ?>" value="<?php $nowMin ?>"/>
<input type="text" name="min" placeholder="Minutes <?php $nowMin ?>" value="<?php $nowMin ?>"/>
<input type="text" name="sec" placeholder="Seconds<?php $nowSec ?>" value="<?php $nowSec ?>"/>
<input type="text" name="sec" placeholder="Seconds<?php $nowSec ?>" value="<?php $nowSec ?>"/>
<input type="submit" id="button">
<input type="submit" id="button">
</form>
</form>
<?php
<?php
$format = 'd-m-Y h:i:s';
$format = 'd-m-Y H:i:s';
$queryTime = $_POST['day'] . "-" . $_POST['month'] . "-" . $_POST['year'] . " " . $_POST['hour'] . ":" . $_POST['min'] . ":" . $_POST['sec'];
$queryTime = $_POST['day'] . "-" . date('m',strtotime($_POST['month'])) . "-" . $_POST['year'] . " " . $_POST['hour'] . ":" . $_POST['min'] . ":" . $_POST['sec'];
if (date($format,strtotime($queryTime)) == $queryTime) {
if (date($format,strtotime($queryTime)) == $queryTime) {
$now = new DateTime(strtotime($queryTime), new DateTimeZone('America/Los_Angeles'));
try {
$now = new DateTime(date("c",strtotime($queryTime)));
} catch (Exception $e) {
echo $e->getMessage();
exit(1);
}
} else {
} else {
echo "You entered:" . $queryTime . "<hr style='display:block;'>";
echo "You entered: " . $queryTime . "<hr style='display:block;'>";
exit;
exit;
}
}
$timezones = array(
$timezones = array(
'EST' => new DateTimeZone('America/Panama'),
'EST' => 'America/Panama',
'UTC' => new DateTimeZone('Europe/London'),
'UTC' => 'Europe/London',
'CCT' => new DateTimeZone('Asia/Hong_Kong'),
'CCT' => 'Asia/Hong_Kong',
'PST' => new DateTimeZone('America/Los_Angeles'),
'PST' => 'America/Los_Angeles',
);
);
echo "You entered:" . $now->format($format) . "<hr style='display:block;'>";
echo "You entered: " . $now->format($format) . "<hr style='display:block;'>";
foreach ($timezones as $zone) {
foreach ($timezones as $zone) {
$now = new DateTime($now, new DateTimeZone($zone));
date_timezone_set($now, timezone_open($zone));
print "The time in" . $zone . "is" . $now->format($format) . "<br/>";
echo "The time in " . $zone . " is " . $now->format($format." \G\M\TP") . "<br/>";
}
}
?>
?>