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 sakarya escort sakarya escort serdivan escort izmir escort eporner
akyazı escort sakarya escort ferizli escort sakarya escort geyve escort sakarya escort hendek escort sakarya escort karasu escort sakarya escort sapanca escort serdivan escort webmaster forum
pendik escort atasehir escort