Time and Date Coding

This article discusses how to customize the date and time format

Time

Fusion Ticket downloads with the time set for 24 hours.

To change to 12 hours go to ../includes/lang/site_xx.inc.

xx = language ie. en

site_xx.inc uses // to ignore a line

File: site_xx.inc

 // 24 hour
 //define("time_format","%H:%M");
 // 12 hour
 define("time_format","%I:%M %p");

[top]

Date

Different countries use different date formats.

File: site_xx.inc

 // Euro Day/Date
 //define("date_format","%A %e %B %Y");  [[Sunday 1 February 2009]]
 // US Day/Date
 define("date_format","%A - %B %e, %Y"); [[Sunday - February 1, 2009]]
 
 define("longdate_format","%Y-%m-%d %H:%M:%S"); [[2009-02-01 12:30:34]]
 define("shortdate_format","%e %b %Y");         [[1 Feb 2009]]
 define("shorterdate_format","%h %e");          [[02/1]]

[top]

Characters

Characters are preceded by % ie. %A

Day

A Full textual representation of the day of the week

  Example: Sunday through Saturday 

a A textual representation of a day, three letters

  Example: Sun through Sat 

d Day of the month, 2 digits with leading zeros

 Example: 01 to 31 

e Day of the month without leading zeros

 Example: 1 to 31

j Day of the Year

 Example: 0 to 365 

u Numeric representation of the day of the week

 Example: 0 (for Sunday) through 7 (for Saturday) 

Week

U ISO-8601 week number of year, weeks starting on Monday

 Example: 42 (the 42nd week in the year) 

Month

b A short textual representation of a month, three letters

 Example: Jan through Dec

B A full textual representation of the month

 Example: January through December 

m Numeric representation of a month, with leading zeros

 Example: 01 through 12 

Year

Y A full numeric representation of a year, 4 digits

 Examples: 1999 or 2008 

x A two digit representation of a year

 Examples: 99 or 08 

Full Date

c Abbreviated date with time

 Example:  Thu Feb 19 00:00:00 2008 

D Short date (mm/dd/yy)

 Example: 02/19/09

F Short date (yyyy/mm/dd)

 Example: 2009/02/19

Time

g 12-hour format of an hour without leading zeros

 Example: 1 through 12 

H 24-hour format of an hour with leading zeros

 Example: 00 through 23 

I 12-hour format of an hour with leading zeros

 Example: 01 through 12 

M Minutes with leading zeros

 Example: 00 to 59 

P Lowercase Ante meridiem and Post meridiem

 Example: am or pm 

p Uppercase Ante meridiem and Post meridiem

 Example: AM or PM 

R Hour and minute

 Example: 00:00

S Seconds, with leading zeros

 Example: 00 through 59

T Hour, minute, and second

 Example: 00:00:00 

[top]

Date for non-English sites

Proper display of the entire site (POS, Admin area, Ticket taker area) non-English dates, need to change the locale to e.g. ru_RU.UTF-8 in the file ../includes/functions/datetime_func.php.

Example:

Actual:

ru_RU

Correct:

ru_RU.UTF-8

More about the definition of locales

[top]


<< Back to Advanced Coding

time_and_date.txt · Last modified: 2012/11/20 11:01 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki