How to calculate cumulative time in cumulative days in php? [duplicate]

2

Everyone, okay? I'm new here in the forum.

I searched around every corner and could not find a solution to what I need.

The concept is simple:

What I basically need to develop is a cumulative day counter that does not have a defined end date, so I set a start date (today for example, 7/18/18) and it shows in days / hours / minutes / seconds when time has passed since that date ...

Ex: If 41days have passed: 09hours: 03minutes: 06seconds on 07/18/18

It is important that this date be fixed, so that when reloading the page, the counter does not "reset" or start everything again and that anyone accessing the page sees the same number / time.

The other posts I found outline the difference between two defined dates, I want to define only the first date, there is no second date yet , it needs to accumulate time infinitely and give a echo / display on screen

ThereisawebsitethatdoesexactlywhatIneed,buttheproblemisthattheydonotreleasethecountercode,theyjustletyouembeddarareadysolution.followlink: link

I would like to know how to do this manually so that I can customize 100% of the code (add HTML, CSS, etc.) afterwards and put it on my site.

Thank you in advance.

    
asked by anonymous 19.07.2018 / 00:31

1 answer

0

From what I understand, I think the code below does what you need.

$dtStart = new DateTime("2018-07-20"); 
$dtEnd   = new DateTime("2018-07-25 10:45:44"); 
$dtDiff = $dtStart->diff($dtEnd);
print $dtDiff->format("%d:%H:%I:%S");
    
20.07.2018 / 21:38