cancel
Showing results for 
Search instead for 
Did you mean: 

Display UTC-Timestamp in timezone of user/server

PatrickMueller
Employee
Employee
0 Kudos

Hello,

the view of my WD Component displays UTC-Timestamps in a table (Cell Editor LinkToAction).

The user has the possibility to alter the timestamps by providing date and time.

The controller converts date and time to a UTC-timestamp by using ABAP-Statement CONVERT with timezone of server (sy-zonlo).

The timezone is CET (UTC1). Therefore the fields to enter the time is displayed in UTC1 but the timestamp is displayed as UTC. The user might be confused, because when entering a time in the inputfield, the timestamp will be displayed 1 hour in the past.

The domain of the timestamp is TZNTSTMPS. I also tried to convert the timestamp into a field with domain TZNTSTMPSL, but with the same effect.

Is there a possibility to display the timestamp in the timezone of the server (sy-zonlo) or in the timezone of the user?

Thanks in advance

Patrick

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Yes,

*convert user date to timestamp based on UTC

CONVERT DATE xxxxx TIME nnnnnn INTO TIME STAMP ts TIME ZONE sy-zonlo.

  • covert a timestamp to date and time in users time zone...

CONVERT TIME STAMP time_stamp TIME ZONE tz

INTO [DATE dat] [TIME tim]

[DAYLIGHT SAVING TIME dst].

I assume you dont want the user actually entering timestamps

Dates and times are friendlier.

Cheers

Phil.

PatrickMueller
Employee
Employee
0 Kudos

Thank you Phil,

I already use both commands.

The user can enter a date and time which is already displayed in his timezone (use of command CONVERT TIMESTAMP ... and later when user saves his settings use of command CONVERT DATE lv_date TIME lv_time ...).

The date and time that user has given should be displayed as a timestamp later(LinkToAction in a table column).

Hope I made the problem clear. The date and time that the user can enter is already displayed in his timezone. It's just about the timestamp which is displayed after user has given date and time. That timestamp should be also displayed in the timezone of the user and not in UTC.

Thanks for your help so far.

Patrick

Former Member
0 Kudos

I see,

I have not seen timestamps presented to end users before.

Interesting requirement.

Try Convert UTC Timestamp to DATE / TIME. Add users time zone offset to Time. Adjust date

if required. Convert new DATE and Time back to timestamp.

good luck,

Phil.

Answers (3)

Answers (3)

0 Kudos

Hi Patrick,

I found a standard solution.  If your field is type timestamp this can be used in your coding for constant UTC time calculations.

Now you want to display this to the user.  In your context use a dataelement / domain that uses TSTLC exit example domain BCS_TIMESTAMP dataelement BCS_TIMESTAMP_CREA.

When you bind your UTC timestamp to the context it will auto convert to the user's time zone.  The exit should also convert back to UTC upon user entry.

Regards

Matt

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Personally I created my own field conversion exit for the better input and output of timestamps within Web Dynpro. I then just created a copy of the TZNTSTMPS data element to link to the field exit.

Send me an email (its listed in my business card) and I will send you the code of the field exit as well as some screen shots of it in action to make sure it meets your needs before you install it.

Former Member
0 Kudos

can you explain how to see the field timezone. In the layout of dynpro this field appears grey out.

field CCIHS_IALHIOT-EVTIMEZONE

program SAPLCBIH_IA03

dynpro 1010