Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Epoch time convertor function module

Former Member
0 Likes
3,805

Hi All,

Do we have any function module to conver epoch time.

Epoch time means

The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). Literally speaking the epoch is Unix time 0 (midnight 1/1/1970)

For more details refer

http://www.epochconverter.com/

Regards

Murali.K

5 REPLIES 5
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,945

Hi,

Cant we build the logic by finding the number of seconds by subtracting the current date with 1.1.1970. ?

Kesav

Read only

0 Likes
1,945

Hi,

I dont know ABAP, can you please help me if you can give the code.

Regards

Murali.K

Read only

0 Likes
1,945

Hi,

I searched and got the Unix commnd to get the Epoch time stamp, its date +%s

There are some methods to execute the unix command which i know but I am not sure of any methods which returns the value of the executed command.

I got this syntax from some links and done some modifications which you can try, i have not checked it


types:begin of ty,
line(200), 
end of ty.
data:it type tale of ty.
data: COMMAND(1000) type c. 

command = 'date +%s'
CALL 'SYSTEM' ID 'COMMAND' FIELD COMMAND 
ID 'TAB' FIELD it-*SYS*. 

Check the internal table it.

Please note that i have not tested it.

kesav

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,945

Look at standard FM RKE_TIMESTAMP_CONVERT_INPUT and RKE_TIMESTAMP_CONVERT_OUTPUT, those convert FM refer to a zero date

DATA: REL_DATE            LIKE SY-DATUM  VALUE '19900101', " Bezugsdatum

You could copy the Function group and FM and change this value for '19700101' in the copied FG, or use those FM and add/remove the number of seconds between first day of 1970 and 1990. (20 years, 7305 days, 175320 hours so 631152000 seconds)

Don't forget also that some days are 86401 sec long and not 86400 ([leap seconds|http://en.wikipedia.org/wiki/Leap_seconds])...

Regards,

Raymond

Read only

Ashok-Kumar-M
Product and Topic Expert
Product and Topic Expert
0 Likes
1,945

Hi All,

Use the below code to get UTC timestamp in seconds.

DATA: LV_TIME_UTC TYPE I.


CALL 'ALERTS' ID 'ADMODE'         FIELD 20

                         ID 'OPCODE'         FIELD 30

                         ID 'ACT_TIME'       FIELD LV_TIME_UTC.


WRITE: LV_TIME_UTC. "in seconds. (seconds since Jan-01-1970).


Best Regards,

Ashok.