Check time difference in Javascript

后端 未结 18 1490
梦毁少年i
梦毁少年i 2020-11-22 04:27

How would you check time difference from two text-boxes in Javascript?

18条回答
  •  借酒劲吻你
    2020-11-22 05:01

    grab the input values after form submission in php

    $start_time = $_POST('start_time');
    $end_time =$_POST('end_time');
    $start = $start_time;
    $end = $end_time;
    $datetime1 = new DateTime($end);
    $datetime2 = new DateTime($start);
    //echo $datetime1->format('H:i:s');
    $interval = $datetime1->diff($datetime2);
    $elapsed = $interval->format('%h:%i');
    $time = explode(":",$elapsed);
    $hours = $time[0];
    $minutes = $time[1];
    $tminutes = $minutes + ($hours*60);
    

    the variable $tminutes is total diff in minutes , working hour is $hour . this code is for php use this logic and convert this code to js

提交回复
热议问题