Showing posts with label How to get present time in AX. Show all posts
Showing posts with label How to get present time in AX. Show all posts

Jan 25, 2012

How to get current time in AX ?


Simple code to display timeNow()  in X++ which returns current time

static void timeNowExample(Args _arg)
{
    TimeInMS  i;
    ;

    i = timeNow();
    info(time2str(i,0,0));

}
str time2Str( int _time, int _separator, int _timeFormat)

The parameters of the function time2Str are described as below:

_time            : The number of seconds since midnight.
_separator   : The characters to be used as separators in the text string. Possible values  follow:  
0 – regional settings for the operating system
1 – colon (:) 
2 – point (.)
3 – space ( )
4 – comma (,)
5 – forward slash (/)

_timeFormat  : Determines whether a 12-hour or 24-hour clock is used. Possible values  follow: