These are algorithms to determine the day from the epoch or the time within the day of the timestamp.
Note that this is the way to Ecmascript determines the day, regardless of actual calendar oddities (leap seconds, etc).
function Day(t){
var msPerDay = 86400000;
return Math.floor(t/msPerDay);
}
function timeInDay(t){
var msPerDay = 86400000;
return Math.floor(t % msPerDay);
}