JavaScript Warning – Date.prototype.toLocaleFormat is deprecated
This JavaScript warning Date.prototype.toLocaleFormat is deprecated; consider using Intl.DateTimeFormat instead occurs if user is using the non-standard Date.prototype.toLocaleFormat method.
Message:
Warning: Date.prototype.toLocaleFormat is deprecated; consider using Intl.DateTimeFormat instead
Error Type:
Warning. JavaScript execution won't be halted.
What Happened?
In the code the non-standard Date.prototype.toLocaleFormat method is used but it is depreciated.
Example 1: In this example, the method which is depreciated is used. So the error has occurred.
Javascript
let day = new Date(); let date = day.toLocaleFormat( '%B, %e. %A %Y' ); // Warning here |
Output:
Warning: Date.prototype.toLocaleFormat is deprecated; consider using Intl.DateTimeFormat instead
Example 2: In this example, the method which is depreciated is used. So the error has occurred.
Javascript
let day = new Date(); day.toLocaleFormat( "%Y%m%d" ); // Warning here |
Output:
Warning: Date.prototype.toLocaleFormat is deprecated; consider using Intl.DateTimeFormat instead
Contact Us