angular-moment

Extract time from moment js object

左心房为你撑大大i 提交于 2019-11-28 08:54:15
How do i extract the time using moment.js? "2015-01-16T12:00:00" It should return "12:00:00 pm". The string return will be passed to the timepicker control below. http://jdewit.github.com/bootstrap-timepicker Any idea? If you read the docs ( http://momentjs.com/docs/#/displaying/ ) you can find this format: moment("2015-01-16T12:00:00").format("hh:mm:ss a") See JS Fiddle http://jsfiddle.net/Bjolja/6mn32xhu/ You can do something like this var now = moment(); var time = now.hour() + ':' + now.minutes() + ':' + now.seconds(); time = time + ((now.hour()) >= 12 ? ' PM' : ' AM'); This is the good

Extract time from moment js object

血红的双手。 提交于 2019-11-27 02:02:23
问题 How do i extract the time using moment.js? "2015-01-16T12:00:00" It should return "12:00:00 pm". The string return will be passed to the timepicker control below. http://jdewit.github.com/bootstrap-timepicker Any idea? 回答1: If you read the docs (http://momentjs.com/docs/#/displaying/) you can find this format: moment("2015-01-16T12:00:00").format("hh:mm:ss a") See JS Fiddle http://jsfiddle.net/Bjolja/6mn32xhu/ 回答2: You can do something like this var now = moment(); var time = now.hour() + ':'