Format Date Time Format String turn LocalDateTime

 
 

1. Format String Date Time Format turn LocalDateTime


1
/ * * 2 * String formatted date time format LocalDateTime turn, the following model: . 3 * [2017,7,22] ==> 2017-07-22 00:00:00 . 4 * @param array value: e.g., [ 2017,. 7, 22 is] . 5 * @Returns} {string string date: 2017-07-22 . 6 * / . 7 HE.localDateTimeToString = function (value) { . 8 IF (value!) return '-' . 9 // recombinant collection : complement day of the year, two complement 10 var reDate value.map = (V => String (V) .padStart (2, '0' )) . 11 // non-completion time format, minutes and seconds is not zero 12 is the while (reDate.length <. 6 ) { 13 is reDate.push('00') 14 } 15 return `${d[0]}-${d[1]}-${d[2]} ${d[3]}:${d[4]}` 16 }

 2. Format String LocalDateTime transfer date

var now = [2017,7,22,11,11,10 ];
 // get the array in the first three elements 
var resNow now.splice = (0,. 3 );
 // splicing array element 
var nowStr = var resNow.join ( '-');

 

 

Guess you like

Origin www.cnblogs.com/blogslee/p/11227862.html