<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> <a class="navbar-brand" href="https://sourcecodester.com">Sourcecodester</a> </div> </nav> <div class="col-md-3"></div> <div class="col-md-6 well"> <h3 class="text-primary">PHP - Simple Timestamp Converter</h3> <hr style="border-top:1px dotted #ccc;"/> <div class="col-md-3"></div> <div class="col-md-6"> <form method="POST"> <div class="form-group"> <label>Timestamp:</label> <input type="number" value="<?php echo time();?>" name="time" class="form-control" readonly="readonly"/> </div> <center><button class="btn btn-primary" name="convert"><span class="glyphicon glyphicon-random"></span> Convert</button></center> </form> <br /> <?php include 'converter.php'?> </div> </div> </body> </html>
<?php $time = $_POST['time']; $datetime = "F d, Y H:i:s A"; $date = new DateTime(); $date->setTimestamp($time); $newDate = $date->format($datetime); echo "<h4>The actual Datetime is:</h4>"; echo "<center><h3 class='text-success'>".$newDate."</h3></center>"; } ?>