corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay!
<?php
$version = '0.3.1';
/*
simple php UNIX timestamp converter tool
There's nothing to this, it's all built in to php, I just had need
of a tool to do it easily, worth the three minutes it took to
knock this together...
I've since spruced it up a bit and added reverse functions; I spotted a few
search engine queriers were actually looking for the other-way-around
convertion.
I switched to GET variables, also, which has many advantages here.
note: you can convert both ways at once
;o)
(c) copyright corz.org 2004 ->today
*/
do_header();
//@include $_SERVER['DOCUMENT_ROOT'].'/inc/header.php';
echo '
<form action="',str_replace(' ', '%20', $_SERVER['SCRIPT_NAME']),'" method="get">
<div class="content">
<h1>unix timestamp converter tool</h1>
<h2><code>current unix timestamp: ',strtotime("now"),'</code></h2><br />
<div class="left-column">';
if ((isset($_GET['timestamp'])) and ($_GET['timestamp'] != '')) {
$unix_timestamp = $_GET['timestamp'];
$nice_time = date('d F Y h:i:s A', $unix_timestamp);
echo '
<small><code>Converted "<span class="converted">',$unix_timestamp,'</span>" to.. <br />
<span class="converted">',$nice_time,'</span></code></small><br />';
}
echo '
<h3>Convert a UNIX timestamp to a "real" date and time..</h3>
Input a valid UNIX timestamp, past or future, and get back a human-readable date and time..<br />
<br />
<small>NOTE: You can perform both conversions at once.</small><br />
<br />
<label><span class="enter">Enter a UNIX timestamp..</span><br />
<input type="text" name="timestamp" id="timestamp" maxlength="30" /></label>
<input type="submit" value="Get Real!" />
</div>';
// the right hand side. "real" time to UNIX timestamp..
echo '
<div class="right-column">';
if ((isset($_GET['realtime'])) and ($_GET['realtime'])) {
$user_time = $_GET['realtime'];
$unix_stamp = strtotime($user_time);
echo '
<small><code>Converted "',$user_time,'" to..<br />
<span class="converted">',$unix_stamp,'</span></code></small><br />';
}
echo '
<h3>Convert a "real" date or time to a UNIX timestamp..</h3>
Possible input formats include: "now", "03 November 2001",
"+1 day", "+1 week", "+1 week 2 days 4 hours 2 seconds", "+1 month",
"next Friday", "last Tuesday", etc. try it and see what happens!<br />
<br />
<label><span class="enter">Enter a real time or date..</span><br />
<input type="text" name="realtime" id="realtime" maxlength="99" /></label>
<input type="submit" value="Timestamp!" />
</div>
<div style="clear: both; font-size: 3em;"></div>
</div>
</form>';
echo '
<a href="https://corz.org/engine?section=php%2Fcorz%20function%20library&source=unix-timestamp-to-date.php" class="toplinks">get the (really simple php) source for this tool</a>';
@include $_SERVER['DOCUMENT_ROOT'].'/inc/footer.php';
echo '
</body>
</html>';
/*
fin
*/
/*
function do_header() */
function do_header() {
global $topsize;
echo '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<title>unix timestamp converter (php UNIX timestamp convertor)</title>
<meta name="description" content="simple gui for some php date & time functions, converts between unix time and real time, and the other way around." />
<link rel="stylesheet" href="/inc/css/tools.css" type="text/css" media="screen" />
<style media="screen">
.container {
margin: 0;
width: 100%;
height: 100%;
float: none;
clear: both;
}
.clear {
margin-left: 0;
margin-right: 0;
width: 100%;
clear: both;
font-size: 0px;
}
.converted { color: red; }
.enter { font-size: small; font-weight: bold; }
</style>
</head>
<body>';
}/* end function do_header()
*/
?>