In a blockchain in general there is no objective "time of the transaction", just the time that the transaction was confirmed in a block, and the time it was first seen by the node. If the transaction involves one of the node's addresses, the latter can be found using an API like getwallettransaction.