Baseline Widely available
toDateString()
æ¹æ³ä»¥ç¾å¼è±è¯å人类æè¯»çå½¢å¼è¿åä¸ä¸ªæ¥æå¯¹è±¡æ¥æé¨åçå符串ã
const event = new Date(1993, 6, 28, 14, 39, 7);
console.log(event.toString());
// Expected output: "Wed Jul 28 1993 14:39:07 GMT+0200 (CEST)"
// Note: your timezone may vary
console.log(event.toDateString());
// Expected output: "Wed Jul 28 1993"
è¯æ³ æè¿°
Date
对象å®ä¾å¼ç¨ä¸ä¸ªå
·ä½çæ¶é´ç¹ãè°ç¨ toString
æ¹æ³ä¼ä»¥ç¾å¼è±è¯å人类æè¯»çå½¢å¼è¿åæ¥æå¯¹è±¡çæ ¼å¼åå符串ãå¨ SpiderMonkey éï¼è¯¥åç¬¦ä¸²ç±æ¥æé¨åï¼å¹´ææ¥ï¼åå
¶åçæ¶é´é¨åï¼æ¶åç§åæ¶åºï¼ç»æãææ¶éè¦è·åæ¥æé¨åçå符串ï¼è¿å¯ä»¥ç± toDateString
æ¹æ³å®æã
The toDateString
method is especially useful because compliant engines implementing ECMA-262 may differ in the string obtained from toString
for Date
objects, as the format is implementation-dependent and simple string slicing approaches may not produce consistent results across multiple engines.
toDateString
æ¹æ³çç®å使ç¨
var d = new Date(1993, 6, 28, 14, 39, 7);
println(d.toString()); // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)
println(d.toDateString()); // prints Wed Jul 28 1993
è§è æµè§å¨å
¼å®¹æ§ åè§
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4