Skip to content
Advertisement

How to display days and hours with date() in php

I have a timestamp which calculates remaining time between 2 dates.

$job_expiration = strtotime($job['job_expiration']) - time(); like so.

Right now, I’m showing only 1 day or 2 days with the date() function.

date('j', $job_expiration) like so.

I also want to show hours instead of 2 days. let’s say the time remaining is 1 day 16 hours or only 30 minutes. then I want to show the hours with day too.

1 day, 16 hours or only 30 minutes

how can I do that?

Advertisement

Answer

JavaScript

Sample output:

2 days, 7 hours, 33 minutes and 20 seconds

In your case you should use this function like convert_seconds($job_expiration)

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement