ToDate()
ts
function ToDate(timeValue: any): Date;Converts a SyncJS (Go in server-context) time.Time value (or compatible timestamp) into a native JavaScript Date object. This is especially useful for working with timestamps returned by other SyncJS functions, allowing you to leverage all standard JavaScript date and time methods.
Parameters
| Name | Type | Description |
|---|---|---|
| timeValue | any | A SyncJS time.Time value or compatible timestamp. |
Returns
A native JavaScript Date object representing the same point in time as the input value.
NOTE
Use ToDate() to easily manipulate and format timestamps from SyncJS APIs using standard JavaScript date methods.
Example
ts
var info = StatFileSystemObject("/home/myself/Documents/brochure.pdf");
if (info.Name !== "") {
var ts = ToDate(info.TimeStamp);
// Use ts as any other native JavaScript Date object
Log(ts.toISOString());
}