Issue
I have a date slot in string (12hrs) format eg - "2:45 PM" and a time period to when this slot ends say 15 (mins). So time slots starts at "2: 45 PM" and ends in 15 mins. I want to show the ending time in the same format as time string in 12hrs format.
Example - Slot: "2: 45 PM", ends: 15 endingSlot will be "3: 00 PM"
Solution
I'd use a library for that — e.g. Moment.js:
import * as moment from 'moment';
const slot = '2.45 PM';
const endingSlot = moment(slot, 'h:mm A').add(15, 'minutes').format('h:mm A');
console.log(endingSlot); // 3:00 PM
Answered By - sptmru
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.