Internationalization and localization tools


Locale-Sensitive JavaScript Method

date.toGMTString();

Internationalization (I18n) Method Overview

The toGMTString method converts a date to a string, using GMT time zone. The actual format of the date is browser dependent.

For example:

var date = new Date();
var result = date.toGMTString();
The result is:

result: Wed, 17 Sep 2014 19:52:21 GMT

Click here for additional details.

Note: toGMTString is no longer supported by Web Standards and should be replaced with toUTCString.

I18n Issues

toGMTString should be replaced with toUTCString, and then whether or not calling toUTCString is an i18n issue is dependent on how it is being used in the application. If the date string is not to be displayed in the UI, then there is no need to change it in an internationalized application. However, if you do want to format the date based on the preferred format of the application's locale, then you will need to replace this method call.

Suggested Replacement

To format the date based on locale, call one of the following methods:

toLocaleDateString
toLocaleString
toLocaleTimeString


Globalyzer will detect this method and report it as an i18n issue. If you have determined that the call is being handled correctly, you can use Globalyzer's Ignore Comment functionality to ensure that it isn't picked up in a subsequent scan.



Locale-Sensitive JavaScript Methods

 

Lingoport internationalization and localization services and software