The source for the sample can be found on Linux with MQ installed in /opt/mqm
at /opt/mqm/samp/amqsevta.c
.
In the MQMD
(Message Descriptor) of every message there is a PutDate
and PutTime
field that is always stored in GMT and are each simple 8 digit strings for example:
- PutDate: 20180904 (YYYYMMDD)
- PutTime: 20173948 (HHMMSSSS)
In the sample program it just converts that to the displayed format of 2018/09/04 20:17:39.48
and appends GMT
to the end since it knows this is always in GMT.
/**********************************************************/
/* Timestamp is read from the MQMD - it is always in GMT */
/* regardless of local timezone. Do not want to try to */
/* convert it, because this machine may be a client in a */
/* different timezone than the server generating the */
/* event. So stick to GMT (or UCT if you prefer). */
/**********************************************************/
sprintf(valbuf,"%4.4s/%2.2s/%2.2s %2.2s:%2.2s:%2.2s.%2.2s GMT",
&pMsgDesc->PutDate[0],
&pMsgDesc->PutDate[4],
&pMsgDesc->PutDate[6],
&pMsgDesc->PutTime[0],
&pMsgDesc->PutTime[2],
&pMsgDesc->PutTime[4],
&pMsgDesc->PutTime[6]);
printLine(offset,"Event created",valbuf);
It looks like you could use the c function strptime
to parse the string into a epoch time stamp and then print that in your local time zone.