Timestamps

Last updated:

|Edit this page

PostHog automatically computes timestamps for captured events, but you can also set them manually. For example:

  • If the payload contains timestamp and sent_at fields, the sent_at field is compared to the server time to account for clock skew. The event's timestamp is adjusted by this difference before being stored. This is the method our libraries use.

  • If the payload includes a timestamp but no sent_at field, then timestamp is directly used as the event timestamp.

  • If offset is included in the payload, then this value is interpreted as milliseconds and is subtracted from the capture time recorded by the server to obtain the event timestamp. The first two alternatives have higher priority so offset is ignored if timestamp is present.

  • Finally, as a fallback when no timestamp or offset are included in the payload, the capture time recorded by the server is used as the event timestamp.

To ensure maximum compatibility with PostHog, timestamp and sent_at fields should be in ISO-8601 format like 2023-12-13T15:45:30.123Z or YYYY-MM-DDTHH:MM:SSZ.

Questions?

  • Jennifer
    9 months ago

    Date field not recognized as date

    I'm passing an event property with a value like "2024-08-12T17:18:39.000-04:00" and it seems like it is not recognized as a date (says STRING in the UI). I believe this is valid according to ISO 8601. Can you tell me why it isn't working?

    • Ben
      a month ago

      I have exactly the same problem as Fabian. I'm trying to set a createdAt property on our users and this is not being recognised as a date, meaning I can't use it in filters or targeting for other features.

      This is blocking me from using surveys. Please fix asap

      --EDIT--

      it's being shown as a string but actually under the hood it's parsed as a date and it works if you try filtering on it :)

  • Pawel
    9 months ago

    Change timestamp format in Activity tab

    I would like to display raw timesatamp on activity tab in format for example YYYY-MM-DD HH:mm:SS, not like 5 minutes ago. Is it possible?

    • Justin
      7 months ago

      I created a new column and pasted in a formula like this. You can take the formula to your liking:

      formatDateTime( toTimeZone( toDateTime(properties.$sent_at), 'America/Chicago' ), '%b %d, %H:%i:%s' )

    • Justin
      7 months ago

      properties.$sent_at shows up as: 2024-10-21T09:23:10.798Z

      the formula above produces: Oct 21, 16:23:10

Was this page useful?