on 01-15-2018 11:52 AM
Hi,
I received this format from my Odata_service
Thu Mar 16 2017 19:30:00 GMT+0100 (W. Europe Standard Time)
I would like to convert it into standard datatype like below
9/03/2017
Hi Eric
I just create a function for all my date conversions, here is an example of what you can do:
// Format dates
formatDate: function(format, date){
//var d = new Date(),
var d = date,
month = '' + this.addZero((d.getMonth() + 1)),
day = '' + this.addZero(d.getDate()),
year = d.getFullYear(),
yearShort = d.getFullYear().toString().substr(-2),
hour = this.addZero(d.getHours()),
min = this.addZero(d.getMinutes()),
sec = this.addZero(d.getSeconds());
switch(format){
case "display" : {
return [year, month, day].join('-'); // returns "2016-08-01"
}
break;
case "simple" : {
return [year, month, day].join(''); // returns "20160801"
}
break;
case "slash" : {
return [day, month, year].join('/'); // returns "01/08/2016"
}
break;
case "odata" : {
return [year, month, day].join('-') + "T00:00:00"; // returns "2017-08-16T00:00:00"
}
break;
};
},
Hope this helped 🙂
Regards
Antonette
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I thank you Antonnette
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.