Simple Age Calculator in PHP
Submitted by nurhodelta_17 on Friday, March 9, 2018 - 09:56.
Getting Started
I've used Bootstrap in this tutorial which is included in the downloadable of this tutorial. If you want, you can download bootstrap using this link.Creating our Calculator
Here's the full PHP code of our calculator.- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Simple Age Calculator in PHP</title>
- <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
- </head>
- <body>
- <div class="container">
- <h1 class="page-header text-center">Simple Age Calculator</h1>
- <div class="row">
- <div class="col-sm-4 col-sm-offset-4">
- <form method="POST">
- <div class="form-group">
- <label>Birthday:</label>
- <input type="date" name="birthday" class="form-control" required>
- </div>
- <button type="submit" name="calculate" class="btn btn-primary">Calculate</button>
- </form>
- <?php
- $bday = $_POST['birthday'];
- ?>
- <div class="alert alert-info text-center" style="margin-top:20px;">
- <?php echo 'Age is <b>'.$diff->format('%y').'</b>'; ?>
- </div>
- <?php
- }
- ?>
- </div>
- </div>
- </div>
- </body>
- </html>
Add new comment
- 2294 views