Trying to read the documentation, but can't seem to find what, if anything, is the difference between these. They all seem to accept the same parameters and locales, and they seem to return the same values.
Are they just aliases of the same function? Or is there actually a difference between them?
const locale = 'no-nb'
const options = {
day: '2-digit', month: 'long',
hour: '2-digit', minute: '2-digit'
}
new Date().toLocaleString(locale, options)
"18. mai, 15"
new Date().toLocaleDateString(locale, options)
"18. mai, 15"
new Date().toLocaleTimeString(locale, options)
"18. mai, 15"
Trying to read the documentation, but can't seem to find what, if anything, is the difference between these. They all seem to accept the same parameters and locales, and they seem to return the same values.
Are they just aliases of the same function? Or is there actually a difference between them?
const locale = 'no-nb'
const options = {
day: '2-digit', month: 'long',
hour: '2-digit', minute: '2-digit'
}
new Date().toLocaleString(locale, options)
"18. mai, 15"
new Date().toLocaleDateString(locale, options)
"18. mai, 15"
new Date().toLocaleTimeString(locale, options)
"18. mai, 15"
Share
Improve this question
asked May 18, 2020 at 13:17
SvishSvish
158k180 gold badges476 silver badges629 bronze badges
3
- I'd guess it's the same code except they have different default option values. – Rup Commented May 18, 2020 at 13:24
- 3 Documentation is a great thing. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… – epascarello Commented May 18, 2020 at 13:29
- 1 @epascarello It would be more helpful if you told us which parts of your documentation link are related to the question at hand