javascript - can't obtain the correct hour with moment -


ok recieve hour

"2017-09-12t18:30:00-04:00" 

but when want put hour un format 24hours:

 moment(data[i].hora_llegada, "yyyy-mm-dd hh:mm:ss").format("hh:mm:ss"),¿ 

i obtain output:

"06:30:00" 

this 6:30 need 18:30

this happen when insert next array:

dataassistsuser.push({   actualizacion_registro: data[i].actualizacion_registro,   baja: data[i].baja,   falta: data[i].falta,   fecha_laboral: moment(data[i].fecha_laboral, ['yyyy-mm-dd']).format("yyyy-mm-dd"),   fecha_registro: data[i].fecha_registro,    hora_llegada: moment(data[i].hora_llegada, "yyyy-mm-dd hh:mm:ss").format("h:mm:ss"), //problem here   hora_salida: moment(data[i].hora_salida, "yyyy-mm-dd hh:mm:ss").format("h:mm:ss"), //problem here   id: data[i].id,   total_atraso: moment(data[i].total_atraso, ['yyyy-mm-dd hh:mm:ss']).format('mm:ss'),   user: data[i].user,   user_id: data[i].user_id,   vacacion: data[i].vacacion }); 

change this,

moment(data[i].hora_llegada, "yyyy-mm-dd hh:mm:ss").format("hh:mm:ss") 

into:

moment(data[i].hora_llegada, "yyyy-mm-ddthh:mm:ss").format("hh:mm:ss") 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -