What is the proper way to get below date format using moment.js,
29-OCT-2022 02.10.01.516000000 AM
I tried the below-mentioned code
DD/mm/yyyy HH:mm:ss
Try this
moment().format('Do-MMM-YYYY hh.mm.ss A')
Related
I have to store the date in the database using this format YY-MM-DD hh:mm:ss but I get this 12/20/2018 1:30 AM after select date from the kendo-datetime picker.
I have tried fomat="YY-MM-SS hh:mm:ss" but its not working every time getting above the same format.
Tell me, anyone, how to convert selected date and time to YY-MM-DD hh:mm:ss?
var date = object.dTime;
var newdate = date.split("/").reverse().join("-");
Use moment library in order to format the date into whatever way that you want to display,
moment(date).format('YY-MM-SS hh:mm:ss')
For more detail, look at here
You can use in angular moment js please read moment js implementation.
or you can follow this link both question are something same .
[format date with moment.js
In your html file use this
<input kendo-date-picker
k-format="'dd/MM/yyyy'"
ng-model="model.Date"
name="Date" required />
var date = new Date('12/20/2018 1:30 AM')
date.toISOString().replace('T', ' ').substring(2, 11) + date.toTimeString().substring(0, 8) // "18-12-19 01:30:00"
i select calendar and set "1517380775843" console , i try convert and get format = 20180131093935 GMT+03:00 ,not now time i try select time and convert to human readable data pls help . thanks
<DateTimeField onChange={this.clock} format={"x"} inputFormat={"YYYY/DD/MM HH:mm:ss"}/>
clock=(newDate)=>{
console.log(newDate)
}
Use moment JS to do such operations.
For example:
moment.parseZone(element.requestDate).format('DD-MM-YYYY hh:mm A')
or for converting to a format specified:
moment(dateString,'DD-MM-YYYY hh:mm A')
Visit https://momentjs.com/ for the docs
I have date 14.05.2017 15:32 its polish format of date and time dd.MM.yyyy HH:mm when im using moment library with locales it always set time to default value of 00:00:00.
Here is example code that i've tried to use
Fiddle
console.log(moment('14.05.2017 15:32').format('dd.MM.yyyy HH:mm'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.3/moment.min.js"></script>
Any other suggestions how to parse it?
Expected result:
2017-05-14T15:32:00.004Z
You should replace the 'pl' argument with the explicit format to parse and add the argument to the format method to display it in the same format:
moment('14.05.2017 15:32','DD.MM.YYYY HH:mm').format('DD.MM.YYYY HH:mm')
Fiddle here
i am using moment.js to parse date , following is the date that i am passing as input 16-11-2017 and i want it to be 2017-11-16
selected_date = moment(selected_date).format('YYYY-MM-DD');
console.log(selected_date);
I am getting invalid date when i parse, please refer to image below.
Have you tried giving the format of the original date
moment(selected_date, 'DD-MM-YYYY').format('YYYY-MM-DD');
Try this
selected_date = moment(selected_date, 'DD-MM-YYYY').format('YYYY-MM-DD');
You need to tell moment the input format if it is not in a recognised format.
Try
moment(selected_date, 'DD-MM-YYYY').format('YYYY-MM-DD');
Can you please advise the simplest method to convert date time e.g. "14/03/2016 2:25:15 PM" to ISO format "2016-03-14T14:25:15" in javascript
Thanks
var date = moment();
date.toISOString();
http://momentjs.com/docs/#/displaying/as-iso-string/