Date Formats while extracting data from Cosmos Mongo DB using Azure Databricks.

Swapnil1998
New Contributor III

I have been trying to extract one date field from cosmos which looks like as below:

"lastModifiedDate" : {

        "$date" : 1668443121840

    }

when the above field is extracted using Databricks it gets converted into a date format which looks like this: 2022-11-14T16:25:21.840+0000

I would want to keep the date format as is in Cosmos in the epoch/unix timestamp as this is important for the incremental extraction.

OR

I would like to know is there any pyspark function to convert date format: 2022-11-14T16:25:21.840+0000 back to 1668443121840

Thanks! in advance