Thanks for the link, but when i use that approach $utcdatetime = new MongoDB\BSON\UTCDateTime($orig_date*1000); it change my date and also store it as date type in format 2021-01-25T07:25:59.765+00:00
For example, if my date is today’s date, then multiplying it with 1000 cause date change…
Also, type is Date but what if i want to store it as type Timestamp?
If you are referring to the BSON type Timestamp, don’t use that, stick with the Date type. If you are not then ignore the rest of this response.
A Date will give resolution down to the millsecond, a Timestamp is at second resolution with an ordinal counter. Primarily the Timestamp is used in a Mongodb replicaset members oplog.
BSON has a special timestamp type for internal MongoDB use and is not associated with the regular Date type. This internal timestamp type is a 64 bit value where:
the most significant 32 bits are a time_t value (seconds since the Unix epoch)
the least significant 32 bits are an incrementing ordinal for operations within a given second.
Note
The BSON timestamp type is for internal MongoDB use. For most cases, in application development, you will want to use the BSON date type. See Date for more information.