javascript formats the method of the specified date object

  • 2020-05-30 19:28:52
  • OfStack

This example demonstrates how javascript formats a specified date object. Share with you for your reference. The details are as follows:


/*
*  formatting Date The object is:" 2015-04-17 10 : 20 : 00 " 
* var dateObj = new Date(); 
*/
function formartDate(dateObj){
  var updatetimeval =dateObj.getFullYear()+"-"+(dateObj.getMonth()+1)+"-" +dateObj.getDate()
   +" "+dateObj.getHours()+":"+dateObj.getMinutes()+":"+dateObj.getSeconds();
  return updatetimeval;
}

I hope this article has been helpful to your javascript programming.


Related articles: