Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use date.format in SPConvertDateToISO.js #56

Open
imthenachoman opened this issue Mar 21, 2017 · 6 comments
Open

use date.format in SPConvertDateToISO.js #56

imthenachoman opened this issue Mar 21, 2017 · 6 comments
Labels

Comments

@imthenachoman
Copy link

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
Copy link
Collaborator

purtuga commented Mar 21, 2017

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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

@purtuga
Copy link
Collaborator

purtuga commented Mar 22, 2017 via email

@joshmcrty
Copy link
Collaborator

Confirmed, toISOString() is IE9+ only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants