Now to string

From Kolmafia
Revision as of 23:51, 26 January 2011 by imported>Bale (new in r8944)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Function Syntax

string now_to_string(string format )

  • format is how the return value should be formatted.

Returns the current time (based on your local computer's system settings) in SimpleDateFormat format. Full information on SimpleDateFormat here.

Code Sample

Examples of using now_to_string().

print("Example 1: "+ now_to_string("yyyy.MM.dd G 'at' HH:mm:ss z"));
print("Example 2: "+ now_to_string("EEE, MMM d, ''yy"));
print("Example 3: "+ now_to_string("h:mm a"));
print("Example 4: "+ now_to_string("hh 'o''clock' a, zzzz"));
print("Example 5: "+ now_to_string("K:mm a, z"));
print("Example 6: "+ now_to_string("yyyyy.MMMMM.dd GGG hh:mm aaa"));
print("Example 7: "+ now_to_string("EEE, d MMM yyyy HH:mm:ss Z"));
print("Example 8: "+ now_to_string("yyMMddHHmmssZ"));

This is the output:

Example 1: 2011.01.25 AD at 21:14:56 CST
Example 2: Tue, Jan 25, '11
Example 3: 9:15 PM
Example 4: 09 o'clock PM, Central Standard Time
Example 5: 9:15 PM, CST
Example 6: 02011.January.25 AD 09:16 PM
Example 7: Tue, 25 Jan 2011 21:16:16 -0600
Example 8: 110125211624-0600


See Also

gameday_to_string() | gameday_to_int() | today_to_string() | time_to_string()