HTML and CSS Reference
In-Depth Information
Written Communication: Writing Dates and Times for a Global
Marketplace
The Tulsa New Year's Bash is a strictly local event; thus, you can write the dates and times
using local formats. However, America's date and time conventions are not shared across
the globe. If you are not careful with your dates and times, you risk confusing your interna-
tional readers. For example, the date 10/3/2015 is interpreted as October 3 rd , 2015 in some
countries, and as March 10 th , 2015 in others. Some countries express times in a 12-hour
(AM/PM) format while others use the 24-hour clock.
If you expect your dates and times to be read by an international audience, you need to
ensure that your text corresponds to local standards. One way to do this is to spell out the
month portion of the date, expressing a date as October 3, 2015. Other designers suggest
that a date format with the year expressed first (for example, 2015-10-3) is less likely to be
misinterpreted.
With JavaScript, you can write dates and times in the user's own local format using the
methods
Date .toLocaleString()
Date .toLocaleDateString()
Date .toLocaleTimeString()
where Date is the JavaScript Date object. The toLocaleString() method converts
the Date object to a text string displaying the date and time formatted based on the
conventions employed by the user's computer. The toLocaleDateString() and
toLocaleTimeString() methods do the same except they display only the date and
the time portions, respectively. Thus, a date and time such as October 3, 2015 at
2:45 p.m. would be displayed using the toLocaleString() method as
Tuesday, October 3, 2015 2:45:00 PM
from a computer located in the United States and as
mardi 3 octobre 2015 14:45:00
from a computer located in France. Note that the exact appearance of the string generated
by the toLocaleString() method depends on the date/time settings on the computer
and the settings of the user's Web browser.
As businesses continue to expand to meet the needs of a global market, you should use
JavaScript's Date object in a way that makes it easier to communicate with your interna-
tional customers and clients in a timely fashion.
Hector reviews the current output and sees two things that he wants changed. The
time values should be displayed in 12-hour time rather than 24-hour time. Also, a minute
or second value smaller than 10 should have a 0 placed before its value as a place-
holder. In other words, instead of displaying
14:35:5
Hector wants the time to read
2:35:05 p.m.
Search WWH ::




Custom Search