惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
G
Google Developers Blog
H
Help Net Security
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog RSS Feed
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
D
Docker
Hugging Face - Blog
Hugging Face - Blog
I
InfoQ
博客园 - 司徒正美
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence

Comments for IT Jungle

Will Power Chips Get A Converged Arm Instruction Set Like Z Mainframe CPUs? - IT Jungle Oracle Dips A Toe Into IBM’s EBCDIC World - IT Jungle Guru: Putting Failure Handling In Its Place - IT Jungle Inside The Security Enhancements In ACS - IT Jungle Guru: Assertions, Take 2 - IT Jungle Guru: Claude’s SQL Tip - IT Jungle Guru: Beyond Three-Part Naming – Running SQL Across Remote IBM i Systems - IT Jungle Does AI Mark The End Of The ERP Era? - IT Jungle Guru: Deterministic Application Development With AI - IT Jungle What IBM’s Got Cooking In Db2 For i In The Summer TRs - IT Jungle Guru: Creating Excel Spreadsheets With Python - IT Jungle The Power11 IBM i P05 Entry Machine Finally Arrives - IT Jungle Guru: Analyzing User Session Statistics, Part 1 - IT Jungle Your IBM i Jobs Don’t Live On An Island Anymore - IT Jungle Set Your Library List From A Job Description - IT Jungle GenAI Is The Death Of Deterministic Project Budgeting - IT Jungle Guru: Single Threading A Program Execution - IT Jungle Guru: Where’s The Table? - IT Jungle Big Blue Unveils Bob Premium Pack For IBM i - IT Jungle Guru: SQL Sequences In RPG Let Db2 Handle The Counting - IT Jungle DB2 for i 7.2 Features and Fun, Part 1 - IT Jungle Guru: DateTime Rules Of Thumb - IT Jungle Spring IBM i Tech Refreshes Will Come A Bit Later This Year - IT Jungle As I See It: The Surgical Years - IT Jungle After A Few Short Years, VS Code Passes Rational Developer for i - IT Jungle Guru: Managing The Lifecycle Of Your Service Programs – Updates Without Chaos - IT Jungle Where We Are And Where We Are Headed With AI On IBM i - IT Jungle And Then There Were Two: Big Blue Withdraws IBM i 7.4 - IT Jungle Guru: When Attention Turns To You – Writing Your Own ATTN Program - IT Jungle With Power11, Power Systems "Go To Eleven" - IT Jungle
Present Timestamps in the Local Time Zone - IT Jungle
Michael Sansoterra · 2026-06-19 · via Comments for IT Jungle

The code for this article is available for download.

For companies with locations in multiple time zones that connect to a central iSeries, time stamp presentation can be a problem. For instance, consider a legacy shipping application that records the date and time of a shipment. If the legacy application isn’t time zone aware, the shipments at the various locations will all be stamped with the date and time of the system’s time zone. A desirable solution for this problem would be a routine that can adjust a timestamp from the main time zone to a local time zone.

Fortunately the “Convert Date and Time Format” (QWCCVTDT) API can help. As of V5R3, this API is capable of converting a timestamp from one time zone to another. RPG service program ADJTS, which you can see by clicking here, shows sample subprocedure ADJTIMESTAMP that uses this API for time zone conversion. The subprocedure’s parameters are: an input timestamp, the input timestamp’s time zone followed by the output time zone. The subprocedure returns the timestamp adjusted for the requested time zone.

Here is a free form example that converts the current date and time to Atlantic Standard Time:

AdjustedTime=AdjTimeStamp(%Timestamp:
                          '*SYS':'QN0400AST');

The input/output time zones are the names of time zone (*TIMZON) objects that define the time zone’s name, offset from Coordinated Universal Time (UTC) and daylight savings information. The predefined IBM time zones can be viewed by issuing the WRKTIMZON command or by clicking here. Here are a few examples of the default time zone values:

*TIMZON Name

Offset

Description

Q0000UTC

0:00

Coordinated Universal Time (UTC)

Q0000GMT

0:00

Greenwich Mean Time (GMT)

QN0400AST

-4:00

Atlantic Standard Time (AST)

QN0500EST

-5:00

Eastern Standard Time (EST)

QN0500EST2

-5:00

Eastern Standard Time (EST)

QN0600CST

-6:00

Central Standard Time (CST)

QN0700MST

-7:00

Mountain Standard Time (MST)

QN0700MST2

-7:00

Mountain Standard Time (MST)

QN0700T

-7:00

Mountain Standard Time (T)

QN0800PST

-8:00

Pacific Standard Time (PST)

QN0800U

-8:00

Pacific Standard Time (U)

QN0900AST

-9:00

Alaska Standard Time (AST)

If for some reason IBM doesn’t have one defined to fit your needs, you can create a *TIMZON object with the CRTTIMZON command.

In addition to these pre-defined time zones, the following special values are allowed by the API:

  • *SYS — System Time Zone
  • *UTC — Coordinated Universal Time
  • *JOB — The current job’s defined time zone

This subprocedure can be wrapped with a myriad of related signatures (i.e. parameter lists) to meet any number of variations. For example, a wrapper can be created to accept a numeric date and a numeric time from a legacy application. These two pieces of information can be combined into a timestamp to call the base AdjTimeStamp subprocedure.

For SQL users, an SQL CREATE FUNCTION statement can be used as follows to make the function available to SQL:

Create Function xxxxx/AdjTS 
(parmTimeStamp   Timestamp, 
 parmInTimeZone  Char(10), 
 parmOutTimeZone Char(10)) 
Returns TimeStamp 
Language RPGLE 
External Name 'xxxxx/ADJTS(ADJTIMESTAMP)' 
Parameter Style General 

The function could be used in SQL to convert a timestamp from the system’s time zone to Eastern Standard Time as follows:

Select AdjTS(Timestamp('2006-10-02 10:25:30'),        
       Char('*SYS'),Char('QN0500EST')) 
  From SysIBM/SysDummy1

In order to implement this function, an application would need a way to track time zone by user or location. One approach is to store all of the date and time information in a single base time zone such as Coordinated Univeral Time (UTC) or the central system’s default time zone. The time zone adjustment subprocedure would be used to adjust a timestamp for display purposes. It would also be used to adjust user input to convert it back to the application’s base time zone. A second approach would be to record a time stamp in its native time zone along with the time zone indicator so that it could be properly converted to any other time zone when appropriate.

Applications can quickly jump time zone boundaries for localized date and time display with the use of the QWCCVTDT API.