Reputation: 38663
my datetime format is given below.
var datetime =Wed Apr 8 15:05:00 UTC+0530 2015;
I only want to get the time 15.05
Upvotes: 9
Views: 19189
Reputation:
You need to create moment object from your string. Then append .format()
var date = moment("Wed Apr 8 15:05:00 UTC+0530 2015").format('HH.mm');
alert(date);
var date = moment("Wed Apr 8 15:05:00 2015").format('HH.mm');
alert(date);
If you want to get "15.05", you will need to remove the "UTC+0530", because its modifying your time :) You can see examples here: http://momentjs.com/docs/#/displaying/format/
Upvotes: 0
Reputation: 4037
Use format()
and specify the desired token.
moment().format('HH.mm')
.
Docs for tokens can be found here
Upvotes: 25