PHP - Calculate experience in months, years and days from two given dates

PHP - Calculate experience in months, years and days from two given dates

In this tutorial, I will tell you how to calculate total experience of your job in months, years and days from two given dates using PHP script.

Using this script, you can calculate your age from birth date to present day.

  1. <?php
  2. if(isset($_POST['submit'])){
  3.     $datetime1 = new DateTime($_POST['start_date']);
  4.     $datetime2 = new DateTime($_POST['end_date']);
  5.     $interval = $datetime1->diff($datetime2);
  6.     echo $interval->format('%y years %m months and %d days');
  7. }
  8. ?>
  9. <!DOCTYPE html>
  10. <html>
  11. <head>
  12.     <title>Online Experience Calculator</title>
  13. </head>
  14. <body>
  15. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  16. Start Date : <input type="date" name="start_date" required="required"><br>
  17. End Date : <input type="date" name="end_date" required="required"><br>
  18. <input type="submit" name="submit" value="Calculate">
  19. </form>
  20. </body>
  21. </html>

The $_SERVER["PHP_SELF"] is a super global variable that returns the name and path of the current file.

Phone: (+91) 8800417876
Noida, 201301
sakarya escort sakarya escort bayan sakarya escort serdivan escort sakarya escort sakarya escort serdivan escort
karasu escort akyazı escort serdivan escort akyazı escort ferizli escort sapanca escort serdivan escort söğütlü escort sakarya escort izmit escort arifiye escort erenler escort hendek escort kocaali escort pamukova escort taraklı escort geyve escort