Time elapsed

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
someguyhere
Forum Contributor
Posts: 181
Joined: Sun Jul 27, 2008 3:24 pm

Time elapsed

Post by someguyhere »

I'll preface this by saying I know next to nothing about javascript. I'm pretty good w/ php, so I understand programming logic, but js is NOT my strong suit.

That being said, here's what I'm looking to do: create a clock that shows the time elapsed since a particular date in Years Months Days Hours:Minutes. I want the clock to run live in the browser.

Can someone please point me in the right direction?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Time elapsed

Post by requinix »

Imagine you're writing a script in PHP that continually outputs the elapsed time.

Code: Select all

$elapsed = 12345; // 12,345 seconds have elapsed since the date
do {
    printElapsedTime($elapsed);
    sleep(1);
    $elapsed++;
} while (true);
What would your printElapsedTime() function look like? We can convert that to Javascript once you know the kind of code needed.
Post Reply