2012年7月25日 星期三

javascript date、timestamp

var d = new Date();
var d = new Date(milliseconds);
var d = new Date(dateString);
var d = new Date(year, month, day, hours, minutes, seconds, milliseconds); 



// get date by month
function daysInMonth(month, year)
{
         return new Date(year, month, 0).getDate();
}
 

 function timestamp2date(UNIX_timestamp){
         if(UNIX_timestamp == null)
         {
                 return null;
         }
         else
         {
                 var a = new Date(UNIX_timestamp*1000);
                 var year = a.getFullYear();
                 var month = a.getMonth() + 1;
                 var date = a.getDate();
                 var time = year + '-' + month + '-' + date;
                 return time;
         }
 }





Reference :
JavaScript Date Object

沒有留言:

張貼留言