You can do it just by manipulating 2 integers, followed by dividing them out to give you the num of days, hours, mins, secs.
You'd just want to base both times - current and expiration, on the unix epoch.
Use the php function time() to get the time since the epoch. Pass this number to the javascript. Using javascript, get the elapsed time since the epoch, at the current time. Subtract 1 from the other, do some dividing and et voila! You've the time remaining.
Now, run the func to calculate the time remaining once every second, minute, whatever.
Without the timer part, this is how the forum is able to tell you that something was posted seconds, minutes, hours ago or tell you it was 'yesterday' etc, etc.
http://stackoverflow.com/questions/1090869/why-is-1-1-1970-the-epoch-time
Here's an exerpt from an old project I have.
function makeNiceTime($intTime)
{
$curTime = time();
$strTime = '';
if ( ($curTime-$intTime) < (60))
{
$strTime = sprintf("%d seconds ago", $curTime-$intTime);
}
else if ( ($curTime-$intTime) < (60*60))
{
$strTime = sprintf("%d minutes ago", ($curTime-$intTime) / 60 );
}
else if ( ($curTime-$intTime) < (60*60*24))
{
$strTime = sprintf("%d hours ago", ($curTime-$intTime) / (60*60) );
}
else if ( ($curTime-$intTime) < (60*60*24*7))
{
$strTime = sprintf("%d days ago", ($curTime-$intTime) / (60*60*24) );
}
else
{
$strTime = date("g.i a D j-M Y", $intTime);
}
return $strTime;
}