Quelltext der Datei datetime.php

<?php
$standalone    
true;

define('DIR''../');
$dir DIR;
define('LIB_PATH'DIR '../files/lib/');

include(
'rdf-header.php');

$meta RDFHeader('HTML 4.01');
?>
<h1 id="doktitel">Umrechnung von Zeiten und Daten</h1>
<div id="text">
<?php
$int 
$_POST['int'] ?? '';
$str $_POST['str'] ?? '';

$hint htmlspecialchars($int);
$hstr htmlspecialchars($str);

if (isset(
$_POST['aktion']) && $_POST['aktion'] === 'time') {
    
$_POST['int'] = time();
}

if (
array_key_exists('int'$_POST) || array_key_exists('str'$_POST))
{
    echo 
'<h2>Ergebnis:</h2>';
    if (
$int)
        echo 
'<p>' $hint ' = ' .
            
date('l d F Y - H:i:s'$int) . '</p>';
    elseif (
$str)
        echo 
'<p>' $hstr ' = ' .
            
strtotime($str) . '</p>';

    echo 
'<hr>';
}
?>
<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post">
    <p><label for="int">UNIX-Timestamp </label>
    <input type="text" name="int" id="int" value="<?= $hint ?>"></p>
    <p>oder</p>
    <p><label for="str">Datum </label>
    <input type="text" name="str" id="str" size="35" value="<?= $hstr ?>"> (in <em>angelsächsischer</em> Notation, also z.B. <em><?php echo(date('l d F Y - H:i:s')) ?></em>)</p>
    <p>
        <button type="submit" name="aktion" value="Berechnen">Berechnen</button>
        <button type="submit" name="aktion" value="time">Aktuelle Zeit</button>
    </p>
</form>
<p>Version $Revision: 1.2 $</p>
<ul class="menu">
    <li><a href="." rel="subsection">weitere Scripts</a></li>
    <li><a href="../" rel="contents">Ãœbersicht</a></li>
</ul>
<?php writeFooter($meta'</div>'false);


Copyright © 2001 - 2024 Robert Bienert - Impressum