JAVALSCRIPTは普通の日付を何時間前、何分前、何秒に変えますか?

2605 ワード

New Document function stingToDateTime(postdate){var second=1000;var minutes=second*60;var hors=minutes*60;var dats=hors*24;var moths=dans*30;vat womontths=days*365;var mmmydate=Dadate=Dadate(Dadate=Dadate(Dadate)=Dadate(Dadatatatatatatetetetetetetee(Dadate(Dadate))(Dadadadatatatatatatatatatatatatatatatatadadadadadate(Dadedededededededededededededededede"/"); var nowtime=new Date();var longtime=nowtime.getTime()-myDate.getTime();var showtime=0;if(longtime gt;moths*2){return postdate;}else if(longtime gggggt;moths){returnrn"1ヶ月前";elefts""""""""";elintttdedededededededededededettttttttttttttttttttttttttttttttttttttdededededededededededents""""""""""""""""longtime/days)+「天前」;else if(longtime gt;hors){return(Math.flooor(longtime/hors)+“小时前”);else if(longtimegggt;minutes){return(Math.flooor(longtime/minutes)+“分前”);else if(longtime ggggggggggggggggggt;second){returnrnrn){returnrnrnrn(Math. fter(Math. fftttttttttttttttttttme+tototototome+tototototttttme""""""""""""""""""""""""""teTime(「2009-05-24 15:05:00」);
[Ctrl+A全選注:外部Jsを導入するにはリフレッシュが必要です.]
ネット上ではC〓〓のバックグラウンドで実現する方法があります.調べやすいように下の方に行ってください.
 
  
public string DateStringFromNow(DateTime dt)
{
TimeSpan span = DateTime.Now - dt;
if (span.TotalDays >60)
{
return dt.ToShortDateString();
}
else
if ( span.TotalDays >30 )
{
return
"1 ";
}
else
if (span.TotalDays >14)
{
return
"2 ";
}
else
if (span.TotalDays >7)
{
return
"1 ";
}
else
if (span.TotalDays >1)
{
return
string.Format("{0} ", (int)Math.Floor(span.TotalDays));
}
else
if (span.TotalHours >1)
{
return
string.Format("{0} ", (int)Math.Floor(span.TotalHours));
}
else
if (span.TotalMinutes >1)
{
return
string.Format("{0} ", (int)Math.Floor(span.TotalMinutes));
}
else
if (span.TotalSeconds >=1)
{
return
string.Format("{0} ", (int)Math.Floor(span.TotalSeconds));
}
else
{
return
"1 ";
}
}