Difference between revisions of "Now to string"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
(new in r8944)
 
imported>Alhifar
m (Updated SimpleDateFormat link)
 
Line 15: Line 15:
 
}}|
 
}}|
  
function_description=Returns the current time (based on your local computer's system settings) in SimpleDateFormat format. Full information on [http://download.oracle.com/javase/1.3/docs/api/java/text/SimpleDateFormat.html SimpleDateFormat] here.|
+
function_description=Returns the current time (based on your local computer's system settings) in SimpleDateFormat format. Full information on [http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html SimpleDateFormat] here.|
  
 
code1={{CodeSample|
 
code1={{CodeSample|

Latest revision as of 13:29, 23 January 2014

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()