# ODTIM

> [HTML Version](odtim_sbr.htm)

_Updated November 2018; see History_

**xcall ODTIM, stringfmt, odate, otime, flags**

ODTIM performs the reverse function of [IDTIM](idtim_sbr.md), i.e. it converts an internal format date and/or time to a string format. Its formatting options are much more extensive, however, than the formats allowed by IDTIM. 

**Parameters**

_stringfmt  _([String](string.md))  \[out\]

the formated date/time string is returned here.

_odate  _([Num](num.md))  \[in\]

should contain the internal (aka "separated" – see [IDTIM](idtim_sbr.md) for details) date to be formatted. 0 is taken to mean the current date.

_otime  _([Num](num.md))  \[in\]

should contain the internal time—seconds since midnight—to be displayed, with 0 indicating either the current time (if _odate_ is also 0), or midnight (if _odate_ <> 0). As there are 86400 seconds in 24 hours, values greater than or equal to 86400 may produced undefined results; see Comments below.

_flags  _([Num](num.md))  \[in\]

must specify a sum of desired formatting options from the following table:

| **Value** | **Meaning** |
|------|------|
| \&h00000001 | Omit date from output (ignore all other date related flags) |
| \&h00000002 | Output the day of the week |
| \&h00000004 | Use the full name of the day of the week; else use the first three characters |
| \&h00000008 | Output the month as a number (1-12) and ignore flag \&h0010. |
| \&h00000010 | Output the full name of the month; else use the first character abbreviation |
| \&h00000020 | Output four digit year; else two digit year |
| \&h00000040 | Output the month first, then the day; else the day first, then the month |
| \&h00000080 | If \&h0100 not specified, use spaces to separate the parts of the date, as in 17 Jul 2013. If \&h0100 is also specified (i.e. \&h0080 + \&h0100) then use separator character defined in the language definition file (LDF). |
| \&h00000100 | If \&h0080 not specified, use slashes to separate the parts of the date, as in 7/17/03. If \&h0080 is also specified, use LDF separator character (see above). |
| \&h00000200 | Omit time from output (ignore all other time related flags) |
| \&h00000400 | Omit seconds from the time output |
| \&h00000800 | Use 12 hour time format with AM/PM; else use 24 hour format |
| \&h00001000 | Do not output a separator between the hours and minutes (also see \&h0020000) |
| \&h00002000 | Use colon as the time separator; else use the character defined in the LDF |
| \&h00004000 | Suppress leading zeroes from numeric portion of date. |
| \&h00020000 | Do not output a separator between the minutes and the seconds |
| \&h00200000 | Do not output date punctuation |
| \&h00800000 | Do not output the day |
| \&h01000000 | Do not output the month |
| \&h02000000 | Do not output the year |


[Hex-Decimal Values](hex-decimalvalues.md)



**Comments**

Two special flags values, which override the bit settings in the table above, are also recognized:

•	flags = 0 produces output of the form: 17-Jul-03 13:15:58. 

•	flags = -1 (\&hffffffff) produces output of the form: Monday, July 17, 2013 01:15:58 PM 

In both of the above special cases, the LDF settings will be applied as appropriate.

As of 6.5.1650.1 (see History), _otime_ values >= 86400 are handled as follows: 

•	If the date output is omitted (flags bit \&h0001 set) and 24 hour format is requested (flags bit \&h0800 not set), then otime is treated as a cumulative value with  no particular upper limit, e.g. otime = 455571 results in 126:32:51, which might represent an elapsed time for some activity.  

•	If the date is to be included in the output (flags bit \&h0001 not set), then the odate value specified will be increased by one day for each multiple of 86400 in otime, with otime reduced accordingly.  For example, if odate = 0 and otime = 86401, it will display tomorrow's date and 00:00:01 as the time.

•	If the date output is omitted and 12 hour format requested (flags bits \&h0801) the result is undefined.

**See Also**

The system function [ODTIM()](odtim().md) provides a somewhat simpler syntax for the same operation.

**History**

2018 October, A-Shell 6.5.1650:  special handling of _otime_ >=86400; see Comments.