Difference between pages "Is trendy" and "Format date time"
(Difference between pages)
Jump to navigation
Jump to search
imported>Eliteofdelete |
imported>Bale (r10078 & r10081) |
||
Line 1: | Line 1: | ||
{{ | {{ | ||
− | #vardefine:name| | + | #vardefine:name|format_date_time}}{{ |
− | #vardefine:return_type| | + | #vardefine:return_type|string}}{{ |
FunctionPage| | FunctionPage| | ||
Line 11: | Line 11: | ||
return_type={{#var:return_type}}| | return_type={{#var:return_type}}| | ||
return_also={{#var:return_also}}| | return_also={{#var:return_also}}| | ||
− | parameter1={{Param| | + | parameter1={{Param|string|inFormat}}| |
+ | parameter2={{Param|string|dtg}}| | ||
+ | parameter3={{Param|string|outFormat}}| | ||
+ | p1desc={{pspan|inFormat}} is how the input string is formatted.| | ||
+ | p2desc={{pspan|dtg}} is the time to reformat.| | ||
+ | p3desc={{pspan|outFormat}} is how the output string should be formatted.| | ||
}}| | }}| | ||
− | + | function_description=Full information on [http://download.oracle.com/javase/1.3/docs/api/java/text/SimpleDateFormat.html SimpleDateFormat] here.| | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | function_description= | ||
− | |||
− | |||
code1={{CodeSample| | code1={{CodeSample| | ||
− | title=Code | + | title=Code Sample| |
− | description= | + | description=Examples of using format_date_time().| |
code= | code= | ||
<syntaxhighlight> | <syntaxhighlight> | ||
− | + | string input; | |
− | + | string format; | |
− | + | string informat; | |
− | + | ||
− | + | input = today_to_string(); | |
− | + | informat = "yyyyMMdd"; | |
+ | format = "yyyy MM dd"; | ||
+ | print(input+" * "+format_date_time(informat, input, format)); | ||
+ | format = "yyyy MM dd hh:mm:ss"; | ||
+ | print(input+" * "+format_date_time(informat, input, format)); | ||
+ | input = time_to_string(); | ||
+ | print(input+" * "+format_date_time(informat, input, format)); | ||
+ | informat = "hh:mm:ss z"; | ||
+ | print(input+" * "+format_date_time(informat, input, format)); | ||
</syntaxhighlight>| | </syntaxhighlight>| | ||
− | + | moreinfo= | |
+ | This is the output: | ||
+ | <pre> | ||
+ | 20111206 * 2011 12 06 | ||
+ | 20111206 * 2011 12 06 12:00:00 | ||
+ | 11:43:35 EST * Bad parameter(s) passed to format_date_time | ||
+ | 11:43:35 EST * 1970 01 01 11:43:35 | ||
+ | </pre> | ||
}}| | }}| | ||
− | |||
− | |||
}} | }} | ||
+ | {{SeeAlso|gameday_to_string|gameday_to_int|now_to_string|time_to_string}} | ||
[[Category:Miscellaneous Functions]] | [[Category:Miscellaneous Functions]] |
Revision as of 21:55, 6 December 2011
Function Syntax
string format_date_time(string inFormat ,string dtg ,string outFormat )
- inFormat is how the input string is formatted.
- dtg is the time to reformat.
- outFormat is how the output string should be formatted.
Full information on SimpleDateFormat here.
Code Sample
Examples of using format_date_time().
string input;
string format;
string informat;
input = today_to_string();
informat = "yyyyMMdd";
format = "yyyy MM dd";
print(input+" * "+format_date_time(informat, input, format));
format = "yyyy MM dd hh:mm:ss";
print(input+" * "+format_date_time(informat, input, format));
input = time_to_string();
print(input+" * "+format_date_time(informat, input, format));
informat = "hh:mm:ss z";
print(input+" * "+format_date_time(informat, input, format));
This is the output:
20111206 * 2011 12 06 20111206 * 2011 12 06 12:00:00 11:43:35 EST * Bad parameter(s) passed to format_date_time 11:43:35 EST * 1970 01 01 11:43:35