Question: I just had one question about "Event-Timestamp" AVP.

I know that i should put the epoch time in there, but i mainly concerned about its format, it is what i found in RFC so far:

```
8.21.  Event-Timestamp AVP

 The Event-Timestamp (AVP Code 55) is of type Time, and MAY be
 included in an Accounting-Request and Accounting-Answer messages to
 record the time that the reported event occurred, in seconds since
 January 1, 1900 00:00 UTC.

Time
  The Time format is derived from the OctetString AVP Base Format.
  The string MUST contain four octets, in the same format as the
  first four bytes are in the NTP timestamp format.  The NTP
  Timestamp format is defined in chapter 3 of [SNTP].

  This represents the number of seconds since 0h on 1 January 1900
  with respect to the Coordinated Universal Time (UTC).

  On 6h 28m 16s UTC, 7 February 2036 the time value will overflow.
  SNTP [SNTP] describes a procedure to extend the time to 2104.
  This procedure MUST be supported by all DIAMETER nodes.

```

So, the question is should i first get the system current time (in epoch format) and then convert it to string and pass it to Event-Timestamp directly ?

But the standard says: "`The string MUST contain four octets`". 

I dont know how to achieve this ... could you please elaborate on this ?

Answer: 
Well, the RFC should be re-strictly followed :)
Converting the epoch time to bytes (length = 4) did the trick.

Update:
It didnt really worked out :/

I mean now, the message is ok from AVP format point of view .. however the time is not correct ..

I used below code to create the epoch time and convert to byte array:

```
time_t t = time(NULL);
tm tmp;
tmp.tm_isdst = -1;
tmp = *localtime( &t );
time_t t2 = mktime( &tmp );

bytes[0] = (t2 >> 24) & 0xFF;
bytes[1] = (t2 >> 16) & 0xFF;
bytes[2] = (t2 >> 8) & 0xFF;
bytes[3] = t2 & 0xFF;

```

But as you can see in below screen shot , the time is actually not correct:

[![enter image description here](https://i.stack.imgur.com/TgbCz.png)](https://i.stack.imgur.com/TgbCz.png)

Could you please tell me what i did wrong here ?

Thanks
"fd\_dictfct\_Time\_encode" function is the answer :)