SPServices
SPServices copied to clipboard
use date.format in SPConvertDateToISO.js
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");
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()
)
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).
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.
@sympmarc That is a good point. I've been burned by it myself so I don't blame you.
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
Confirmed, toISOString()
is IE9+ only