tag:blogger.com,1999:blog-8999220862553390592.post8424289514325718438..comments2022-04-11T01:33:57.054+05:00Comments on Linux & Web Development Geek - Tips & Tricks: PHP Get time difference in Hour,Minutes or Seconds.Unknownnoreply@blogger.comBlogger4125tag:blogger.com,1999:blog-8999220862553390592.post-70228084741160867402015-09-26T16:46:50.960+05:002015-09-26T16:46:50.960+05:00how to calculate total log in time of employee in ...how to calculate total log in time of employee in a organization using php my sqlKanagasabai NKhttps://www.blogger.com/profile/07888344529880126811noreply@blogger.comtag:blogger.com,1999:blog-8999220862553390592.post-8038727744477028232015-07-31T10:22:35.289+05:002015-07-31T10:22:35.289+05:00Can anyone one of you help me out how to calculate...Can anyone one of you help me out how to calculate diff between 6:00AM to 6:00PM , those two values i got using jquery timepicker.<br /><br />Thanks in advanceAnonymoushttps://www.blogger.com/profile/08928405222177811721noreply@blogger.comtag:blogger.com,1999:blog-8999220862553390592.post-3975716445130726312014-05-01T01:59:59.643+05:002014-05-01T01:59:59.643+05:00In fact the first code is wrong
$today = new...In fact the first code is wrong <br /> $today = new DateTime(date('y-m-d h:m:s'));<br />this shows minute equals to month, and hour without 24 hour format<br />The right code is:<br /> $today = new DateTime(date('y-m-d H:i:s'));Anonymoushttps://www.blogger.com/profile/13488061006348762414noreply@blogger.comtag:blogger.com,1999:blog-8999220862553390592.post-74927276906283024692014-04-20T13:12:07.838+05:002014-04-20T13:12:07.838+05:00The last bit of this isn't exactly true. For ...The last bit of this isn't exactly true. For instance:<br /><br /> echo $pastDate->s; //return the difference in Second(s)<br /><br />This does not return the difference in seconds, it returns the seconds portion of the difference. Here's an example to illustrate:<br /><br /> $today = new DateTime(date('2014-04-20 01:07:30'));<br /> $pastDate = $today->diff(new DateTime('2012-09-11 10:25:00'));<br /><br />Then this:<br /><br /> echo $pastDate->s;<br /><br />Will return 30, because this is the difference in the seconds portion of the timestamps. If you want to get the actual number of seconds between the timestamps, you could do something like this:<br /><br /> echo ($pastDate->days * 86400 + $pastDate->h * 3600 + $pastDate->i * 60 + $pastDate->s);Anonymoushttps://www.blogger.com/profile/16040211113447898226noreply@blogger.com