ABAP Timestamp

To get the current time as a timestamp you can use GET TIME STAMP.

GET TIME STAMP FIELD DATA(lv_timestamp).

Adding seconds to a timestamp

To add to a timestamp you can use the cl_abap_tstmp class.

DATA(lv_new_timestamp) = cl_abap_tstmp=>add(
    tstmp = lv_timestamp
    secs  = ( 60 * 60  ) " 1hour
).

Subtracting seconds from a timestamp

Subtraction is also possible with the cl_abap_tstmp class.

DATA(lv_new_timestamp) = cl_abap_tstmp=>subtractsecs(
    tstmp = lv_timestamp
    secs  = ( 60 * 60  ) " 1hour
).

Subtract one timestamp from another timestamp

The cl_abap_tstmp class can also subtract one timestamp from another timestamp.

DATA(lv_diff) = cl_abap_tstmp=>subtract(
    tstmp1 = lv_new_timestamp
    tstmp2 = lv_timestamp
).
"lv_diff is in seconds