0

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("-");
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Kapil Soni
  • 1,003
  • 2
  • 15
  • 37

4 Answers4

1

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

deepak thomas
  • 1,118
  • 9
  • 23
0

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

0

In your html file use this

<input kendo-date-picker
    k-format="'dd/MM/yyyy'"
    ng-model="model.Date"
    name="Date" required />
Ha. Huynh
  • 1,772
  • 11
  • 27
Robin
  • 1
  • 3
  • since you are using kendo date time picker this is the most relevent solution since it uses inbuilt kendo method for doing so. – Robin Dec 20 '18 at 06:58
-1
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"
亚里士朱德
  • 510
  • 5
  • 15