The source of unix_time.php (click to demo the file) viewed 1414 times.
If I wrote this code, then it is licensed under the GPL. If someone else wrote it, then please ask them if you want to use the code.
<?php
$time_format = "j F Y, G:i s";
$timestamp = time();
$today = date($time_format);
echo "Current Unix Timestamp: <b>$timestamp</b><br>";
echo "Formatted to English Timestamp: <b>$today</b><br><br>";
?>
<form name="form1" method="post">
Unix Timestamp: <input type="text" name="unix_to_english" value="<?php echo $_POST[unix_to_english]; ?>"> <input type="submit" name="Submit" value="Convert to English">
</form>
<?php
$converted_timestamp = date($time_format, $_POST[unix_to_english]);
echo "<b>$converted_timestamp</b><br>";
// Getting current time for drop down box
if ($day == false) {
$c_day = date("j");
$c_month = date("n");
$c_year = date("Y");
$c_hour = date("G");
$c_min = date("i");
$c_min = round($c_min);
$c_sec = date("s");
$c_sec = round($c_sec);
}
?>
<br><br>
<form name="form2" method="post">
<select name="day">
<?php
if ($_POST[day] == true)
{
$c_day = $_POST[day];
}
for ($i = 1; $i <= 31; $i++) {
if ($i == $c_day) {
echo "<option value=$i selected>$i</option>";
}
else
{
echo "<option value=$i>$i</option>";
}
}
?>
</select>
/<select name="month">
<?php
if ($_POST[month] == true)
{
$c_month = $_POST[month];
}
for ($i = 1; $i <= 12; $i++) {
if ($i == $c_month) {
echo "<option value=$i selected>$i</option>";
}
else
{
echo "<option value=$i>$i</option>";
}
}
?>
</select>
/<select name="year">
<?php
if ($_POST[year] == true)
{
$c_year = $_POST[year];
}
for ($i = 1970; $i <= 2038; $i++) {
if ($i == $c_year) {
echo "<option value=$i selected>$i</option>";
}
else
{
echo "<option value=$i>$i</option>";
}
}
?>
</select>
<select name="hour">
<?php
if ($_POST[hour] == true)
{
$c_hour = $_POST[hour];
}
for ($i = 0; $i <= 23; $i++) {
if ($i == $c_hour) {
echo "<option value=$i selected>$i</option>";
}
else
{
echo "<option value=$i>$i</option>";
}
}
?>
</select>
:<select name="min">
<?php
if ($_POST[min] == true)
{
$c_min = $_POST[min];
}
for ($i = 0; $i <= 59; $i++) {
if ($i == $c_min) {
echo "<option value=$i selected>$i</option>";
}
else
{
echo "<option value=$i>$i</option>";
}
}
?>
</select>
<select name="sec">
<?php
if ($_POST[sec] == true)
{
$c_sec = $_POST[sec];
}
for ($i = 0; $i <= 59; $i++) {
if ($i == $c_sec) {
echo "<option value=$i selected>$i</option>";
}
else
{
echo "<option value=$i>$i</option>";
}
}
?>
</select>
<input type="submit" name="Submit2" value="Convert to Unix"><br><br>
<?php
if ($_POST[year] == false)
{
$hour = 1;
$min = 0;
$sec = 0;
$month = 1;
$day = 1;
$year = 1970;
}
else
{
$hour = $_POST[hour];
$min = $_POST['min'];
$sec = $_POST[sec];
$month = $_POST[month];
$day = $_POST[day];
$year = $_POST[year];
}
$converted_time = mktime($hour, $min, $sec, $month, $day, $year);
echo "<b>$converted_time</b>";
?>
If you want to have a look at the source code, chose a file from this list:
To colour code your own PHP paste it here: