• Copyright© 2025 xPralak Designs - Joseph Downey
<div id="page">
<?php
include('includes/header.php');
?>
<div class="page-heading">
<h1>Joe's Time Understood</h1>
</div>
<?php
error_reporting(E_ALL); // Enable full error reporting
// Retrieve form data safely
$step = $_POST['step'] ?? 0;
$years = filter_input(INPUT_POST, 'years', FILTER_SANITIZE_NUMBER_INT);
date_default_timezone_set('America/New_York');
// Get current date and time
$current_year = (int)date("Y");
$current_day_of_year = (int)date("z") + 1; // 'z' gives zero-based day, so add 1
$current_hour = (int)date("G"); // 24-hour format (0-23)
$current_minute = (int)date("i"); // Minutes (0-59)
$current_second = (int)date("s"); // Seconds (0-59)
$current_millisecond = (int)(microtime(true) * 1000) % 1000; // Milliseconds
if ($step == 0) { // First-time form display
?>
<form action="time.php" method="POST">
<label for="years">Enter Number of Years:</label>
<input type="number" id="years" name="years" min="1" step="1" placeholder="e.g., 5" required>
<br><br>
<input type="hidden" name="step" value="1">
<input type="submit" name="submit" value="Submit">
</form>
<?php
} else { // Process and display results
if (!is_numeric($years) || $years < 1) {
echo "<p style='color: red;'>Please enter a valid number of years.</p>";
} else {
// Time calculations
$days_per_year = 365;
$hours_per_day = 24;
$minutes_per_hour = 60;
$seconds_per_minute = 60;
$milliseconds_per_second = 1000;
$millennium = 1000; // 1 millennium = 1000 years
// Convert input years to time units
$total_millennia = $years / $millennium;
$total_days = $years * $days_per_year;
$total_hours = $total_days * $hours_per_day;
$total_minutes = $total_hours * $minutes_per_hour;
$total_seconds = $total_minutes * $seconds_per_minute;
$total_milliseconds = $total_seconds * $milliseconds_per_second;
echo "<h3>In <strong>" . number_format($years) . "</strong> years, there are:</h3>";
echo "<ul>
<li><strong>" . number_format($total_millennia, 3) . "</strong> millennia</li>
<li><strong>" . number_format($total_days) . "</strong> days</li>
<li><strong>" . number_format($total_hours) . "</strong> hours</li>
<li><strong>" . number_format($total_minutes) . "</strong> minutes</li>
<li><strong>" . number_format($total_seconds) . "</strong> seconds</li>
<li><strong>" . number_format($total_milliseconds) . "</strong> milliseconds</li>
</ul>";
// ==== Time Since Year 0 AD ====
$total_days_since_0_AD = ($current_year * $days_per_year) + $current_day_of_year;
$total_hours_since_0_AD = $total_days_since_0_AD * $hours_per_day + $current_hour;
$total_minutes_since_0_AD = $total_hours_since_0_AD * $minutes_per_hour + $current_minute;
$total_seconds_since_0_AD = $total_minutes_since_0_AD * $seconds_per_minute + $current_second;
$total_milliseconds_since_0_AD = $total_seconds_since_0_AD * $milliseconds_per_second + $current_millisecond;
echo "<h3>From Year 0 A.D. to Now (<strong>$current_year</strong> at <strong>$current_hour:$current_minute:$current_second.$current_millisecond EST</strong>):</h3>";
echo "<ul>
<li><strong>" . number_format($current_year / $millennium, 3) . "</strong> millennia</li>
<li><strong>" . number_format($total_days_since_0_AD) . "</strong> days</li>
<li><strong>" . number_format($total_hours_since_0_AD) . "</strong> hours</li>
<li><strong>" . number_format($total_minutes_since_0_AD) . "</strong> minutes</li>
<li><strong>" . number_format($total_seconds_since_0_AD) . "</strong> seconds</li>
<li><strong>" . number_format($total_milliseconds_since_0_AD) . "</strong> milliseconds</li>
</ul>";
}
?>
<form action="time.php" method="POST">
<input type="hidden" name="step" value="0">
<input type="submit" name="submit" value="Try Again">
</form>
<?php
}
?>
</div>
<?php include('includes/footer.php'); ?>