Search code examples
phpdatetimeunix-timestamp

I just want to show time in a 24 hour clock in php when my form submits


I am using below line of code

$time = $_SERVER['REQUEST_TIME'];

but in my database it shows like following format. (unixtimestamp)

1419957753

How i can change it?


Solution

  • I would use date() instead, which is something I've just done on my website:

    <?php echo date("D M d, Y G:i a"); ?>
    

    it's explained in a little more detail here, as regards formatting. Maybe you want:

    <?php echo date("G:i"); ?>
    

    the formatting is up to you, but date() is what you want ;-)