/    Sign up×
Community /Pin to ProfileBookmark

Time Difference

I’m at a loss on how to show the difference in time with my script, I have thus far:

[code=php]<?php

$date_today = 1263305013;

$last_update = 1263393544;

if($date_today > $last_update)
{
echo ‘New day’;
}else{
echo ‘Still time to go till next update: ‘;

echo date(‘G:i:s’,abs($date_today – $last_update));
}

echo ‘<br />’;
echo ‘Last Update: ‘. date(“F j, Y, g:i:s”,$date_today).'<br />’;
echo ‘Next Update: ‘ . date(“F j, Y, g:i:s”,$last_update).'<br />’;

?>[/code]

But I would like to show Still time to go till next update: 18 hours 23 min. Any suggestions on how to achieve this? thanks

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@SrWebDeveloperJan 12.2010 — You might try something like this:

[code=php]$dateDiff = $date1 - $date2;
$fullDays = floor($dateDiff/(60*60*24));
$fullHours = floor(($dateDiff-($fullDays*60*60*24))/(60*60));
$fullMinutes = floor(($dateDiff-($fullDays*60*60*24)-($fullHours*60*60))/60);
echo "Differernce is $fullDays days, $fullHours hours and $fullMinutes minutes."; [/code]


-jim
×

Success!

Help @happyeddie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...