Lasso Soft Inc. > Home

[ date->format ]

Method

[Date->Format] outputs a Lasso date object in a specified format.

The method requires one string parameter which defines how the date should be formatted. An optional [Locale] parameter further formats the date according to the locale, for example to localize month and day names.

Lasso uses ICU for all date and time handling. The full set of ICU date/time formatting and parsing flags are available and are listed in the table below.

This data is taken from ICU: Formatting Dates and Times. See that page for greater details.

Symbol Meaning Example
G era designator G AD
y year yy
yyyy or y
96
1996
Y year of "Week of Year" Y 1997
u extended year u 4601
Q quarter Q or QQ
QQQ
QQQQ
02
Q2
2nd quarter
q Stand Alone quarter q or qq
qqq
qqqq
02
Q2
2nd quarter
M month in year M or MM
MMM
MMMM
MMMMM
09
Sept
September
S
L Stand Alone month in year L or LL
LLL
LLLL
LLLLL
09
Sept
September
S
w week of year w or ww 27
W week of month W 2
d day in month d
dd
2
02
D day of year D 189
F day of week in month   2 (2nd Wed in July)
g modified julian day g 2451334
E day of week E, EE, or EEE
EEEE
EEEEE
Tues
Tuesday
T
e local day of week
example: if Monday is 1st day, Tuesday is 2nd
e or ee
eee
eeee
eeeee
2
Tues
Tuesday
T
c Stand Alone local day of week e or ee
eee
eeee
eeeee
2
Tues
Tuesday
T
a am/pm marker a pm
h hour in am/pm (1~12) h
hh
7
07
H hour in day (0~23) H
HH
0
00
k hour in day (1~24) k
kk
24
24
K hour in am/pm (0~11) K
KK
0
00
m minute in hour m
mm
4
04
s second in minute s
ss
5
05
S millisecond
rounds to count of letters
S
SS
SSS
SSSS
2
24
235
2350
A milliseconds in day A 61201235
z Time Zone: specific non-location z, zz, or zzz
zzzz
PDT
Pacific Daylight Time
Z Time Zone: RFC 822
Time Zone: localized GMT
Z, ZZ, or ZZZ
ZZZZ
-0800
GMT-08:00
v Time Zone: generic non-location v
vvvv
PT
Pacific Time or United States (Los Angeles)
V Time Zone: generic non-location V PT
VVVV Time Zone: generic location VVVV United States (Los Angeles)
W week in month   2
' escape for text ' (nothing)
' ' two single quotes produce one ' ' '

For compatibility purposes, Lasso 9 accepts and converts all Lasso Professional 8.6 date/time formatting/parsing flags.

  • Syntax
Date Object->format('Format String')
Date Object->format(-format='Format String')
Date Object->format('Format String', -locale=Locale Object)
Date Object->format(-format='Format String', -locale=Locale Object)
Examples
  • Beginner
  • Intermediate

To format a Lasso date:

Use the [Date->Format] method. The following example formats a Lasso date as a MySQL timestamp.

Code

date('2011-02-19 16:33:48')->format('yMMddHHmmss')')

Result

20110219163348

To format a date using a locale:

Use the [Date->Format] method with an appropriate locale. Thailand (and many countries in Asia) uses a Buddhist calendar, so its years differ from the Gregorian calendar used by most of the Western cultures. The following example formats a date object as a timestamp and for the Thailand locale.

Code

date('2011-02-19 16:33:48')->format('y-MM-dd HH:mm:ss', -locale=locale('th','TH'))

Result

2554-02-19 16:33:48

Recent Comments

local('timestamp' = date('2011-02-19 16:33:48')->format('yMMddHHmmss'))
#timestamp

Posted on: 08 February 2013

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft