/**
*
* Returns a formatted date how long it is from now, such as September 5, 2009 14:15:23
* For example: the current time is September 5, 2009 14:15:23 timeLong=10 seconds then return: September 5, 2009 14:15:33
*
* @param int timeLong a
* @param String formatString YYYY-MM-DD hh :mm:ss
*
*/
function getOneFormatDate(timeLong,formatString)
{
timeLong=parseInt(timeLong);
timeLong=timeLong*1000;
var myDate=new Date();
var futureDate=new Date(parseInt(myDate.getTime()) timeLong);
var year=futureDate.getYear();
var month=futureDate.getMonth();
var day=futureDate.getDate();
var hour=futureDate.getHours();
var minute=futureDate.getMinutes();
var second=futureDate.getSeconds();
if(hour<10)
{
hour="0" hour;
}
if(minute<10)
{
minute="0" minute;
}
if(second<10)
{
second="0" second;
}
formatString=formatString.replace("YYYY",year);
formatString=formatString.replace("MM",month);
formatString=formatString.replace("DD",day);
formatString=formatString.replace("hh",hour);
formatString=formatString.replace("mm",minute);
formatString=formatString.replace("ss",second);
return formatString;
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn