sympmarc / SPServices

SPServices is a jQuery library which abstracts SharePoint's Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server install.
MIT License
207 stars 62 forks source link

use date.format in SPConvertDateToISO.js #56

Open imthenachoman opened 7 years ago

imthenachoman commented 7 years ago

I don't want to muck around with other people's code but wouldn't it make more sense to use Date.format in SPConvertDateToISO.js? (new Date()).format("yyyy-MM-dd HH:mm:ss");

purtuga commented 7 years ago

Where are you getting this Date#format method from? I don't see it as part of the JavaScript Date class..

(ps> the right method to use is probably toISOString())

imthenachoman commented 7 years ago

It is included with the JS libraries that MS includes. Check http://sharepoint.stackexchange.com/a/73713/42332. There is also String.format (https://sharepoint.stackexchange.com/questions/160806/changing-date-format-using-javascript).

sympmarc commented 7 years ago

I've rarely wanted to take any dependencies on Microsoft's JavaScript because they used to change it around frequently, with no warning, documentation, or discussion.

.toISOString() is definitely the right way to go these days. I can't remember if I simply didn't know about it at the time or if didn't exist in IE8, which I was usually writing for in the early days.

imthenachoman commented 7 years ago

@sympmarc That is a good point. I've been burned by it myself so I don't blame you.

purtuga commented 7 years ago

Marc, I don't think IE supported that method in earlier versions, because I too was using a custom function to output ISO dates.


Paul T

joshmcrty commented 7 years ago

Confirmed, toISOString() is IE9+ only