Timestamp is not part of the regular messages. Therefore you cannot extract it.
There is a spec (as mentioned by @Dmitry), but this only applies to specific types of messages. Typically those that are NOT realtime, such as offline and publishing the last pubsub message of a node when a new subscription is created. These are messages with an inherent delay built into the
Due to specs time is required attribute for XMPP message: