0

Hello i have a script and when she get time played(im using for game) she display to me the time like this: 1026.984375

I'm using this method $playertime = ( is_numeric($p['time_online']) ) ? ceil($p['time_online']/60).' m' : $p['time_online'];

But she display to me like this: 3052 m, i need to advence this script to display to me like: 50 H, 8 m, 6s.

  • I had no clue that PHP scripts can have genders. – cteski Nov 08 '16 at 21:45
  • You won't be able to get seconds. It looks like the finest your data will get is minutes. – Jaime Nov 08 '16 at 22:00
  • Possible duplicate of [Converting timestamp to time ago in PHP e.g 1 day ago, 2 days ago...](http://stackoverflow.com/questions/1416697/converting-timestamp-to-time-ago-in-php-e-g-1-day-ago-2-days-ago) – Alister Bulman Nov 08 '16 at 22:43

2 Answers2

0

You can use PHP's DateInterval::createFromDateString (maybe in your case some rouding to seconds will be needed), then you will have a DateInterval object and then you could format it to any format you need.

Valentas
  • 2,135
  • 1
  • 17
  • 21
0

I fixed it with a time ago function thanks.