Passing a timestamp through a PHP form, and formatting it on second page
<p>This is a very basic project for a PHP class I am in - no databases involved so the data isn't going anywhere except the next page.</p>

<p>Currently, I am formatting the date on the page with the form using a hidden field, and it gets passed through in the URL post-formatting (with all the spaces punctuation).  That satisfies the requirements of the assignment, but does not seem like the cleanest way to do this.</p>

<p>The form is "Comp2.php" and the page that displays the data is "Comp2b.php"</p>

<p>Here are the code segments in question:<br>
(There are other fields in play of course, but I left them out since they are just text)</p>

<p>Comp2.php</p>

<pre><code>&lt;?php
    if (isset($_POST['submit'])) {
        $valid = true;
        $dateadded = $_POST['dateadded'];

        if ($valid) {
            header("Location: Comp2b.php?albumid=$albumid&amp;album=$album&amp;artist=$artist&amp;dateadded=$dateadded");
            exit();
        }
    } else {
        $albumid="";
        $artist="";
        $album="";
        $price="";
        $type="";
        $playlists[0]="";
        $genre="";
        $tracks="";

    }
?&gt;
    &lt;form method="post" action="Comp2.php"&gt;

&lt;?php $currentDate = date('l, F d, Y h:i:s a.') ?&gt;

            &lt;input type="hidden" name="dateadded" value="&lt;?php echo $currentDate; ?&gt;"&gt;
</code></pre>

<p>Then the rest of the form continues...</p>

<p>This is
Comp2b.php:</p>

<pre><code>&lt;?php

    echo "Album ID: &lt;strong&gt;";
    echo $_GET['albumid']."&lt;/strong&gt;&lt;p&gt;&lt;strong&gt;".$_GET['album']."&lt;/strong&gt; by &lt;strong&gt;".$_GET['artist']."&lt;/strong&gt; added on ".$_GET['dateadded'];

?&gt;
</code></pre>

<p>How can I pass something like <code>date()</code> or <code>time()</code> through the form, and do the formatting i.e., <code>date('l, F d, Y h:i:s a.', $dateadded)</code> on my second page instead of passing a full string through the URL?</p>