BlogGitHub
Core APIs Date And Time Create and parse date/time values, add or subtract time, convert UTC/local values, and format output.

Create And Parse Values

Use /ork/cl_date_time class methods for creation from ABAP dates, times, timestamps, or text formats.

DATA(now) = /ork/cl_date_time=>s_now( ).
DATA(from_stamp) = /ork/cl_date_time=>s_new_from_abap_date_time(
  date = sy-datum
  time = sy-uzeit
).

Parsing methods return typed date/time interfaces and raise /ork/cx_exception when input cannot be interpreted.

DATA(parsed) = /ork/cl_date_time=>s_parse( `2026-05-14T10:30:00Z` ).

Add And Subtract Time

Date/time values expose arithmetic through /ork/if_date_time. Durations are represented with /ork/if_duration.

DATA(in_one_hour) = now->add_hours( 1 ).
DATA(yesterday) = now->subtract(
  /ork/cl_duration=>s_new_from_days( 1 )
).

Convert UTC And Local Values

Use to_utc, to_local, to_system, and UTC offset helpers when moving between storage and presentation boundaries.

DATA(utc_value) = now->to_utc( ).
DATA(system_value) = utc_value->to_system( ).

Format Output

For common formats, use /ork/cl_date_time formatting helpers. For culture-aware formatting, pair date/time values with the formatting package.

DATA(date_text) = /ork/cl_date_time=>s_format_date( sy-datum ).
DATA(stamp_text) = /ork/cl_date_time=>s_format_stamp( now->raw_utc_stamp( ) ).