Display Formats

Dates and times are displayed in a variety of formats. Example 11-16 used a date format string of m/d/y G.i:s. Table 11-2 shows other possible components for those formats.

Table 11-2. Time-formatting values

Format Meaning Example value

Table 11-2. Time-formatting values (continued)

Format Meaning Example value

D Day of the month 01

D Day or the week Sun

F Month name January h Hours in 12-hour format with leading zeros 04

H Hours in 24-hour format with leading zeros 16

g Hours in 12-hour format without leading zeros 4

G Hours in 24-hour format without leading zeros 16

i Minutes 35

j Day of the month 2

l Day of the week as a name Sunday

m Month of the year abbreviated to three characters Jul

M Month of the year July

N Month of the year as number without leading zeros 7

s Seconds of the hour 58

R Standardized date format Thu, 15 Dec 2005 16:49:39-0600

U Timestamp 1134512479

y Two-digit year 25

Y Four-digit year 2025

z Day of year 234

Z GMT offset in seconds (Greenwich Mean Time) -21600 (-6*60*60)

Was this article helpful?

0 0

Post a comment