Reputation: 141
May i ask you how can i calculate the period by deduct two time parameter like below
$time_1 = $rows['code_send_time'];
$period = time() - $time_1;
after I echo the $period how can I exchange to minute and know how many minutes has passed?
The result after I deduct is "151341193030" and I want the result will be "30" (mins) or "1800" (seconds)
Thanks for your help!
Upvotes: 0
Views: 203
Reputation: 6300
$time_1 = $rows['code_send_time'];
// As you said you get 151341193030 here
$period = time() - $time_1;
$period contains the number of seconds. So if you want to get minutes you can divide it by 60 and it you'd like to get hours then divide it by 3600.
Upvotes: 0
Reputation: 3194
You can use the DateTime
object for this. If you check out the docs there is this method: DateTime::diff
Upvotes: 1
Reputation: 1792
http://snipplr.com/view/1459/sec2hms/
Add what you have to this:
sec2hms( $period );
Upvotes: 0