API ReferenceAdvanced utilities and typesFunction
dateToEthereumTimestamp()
function dateToEthereumTimestamp(d): bigint;Converts a JavaScript Date to the Unix-seconds bigint the protocol uses for every onchain
timestamp, such as expirationTimestampSeconds on
CreateStaticLOCParams. Sub-second precision is dropped
(the value rounds down to the whole second). Inverse of ethereumTimestampToDate.
Parameters
| Parameter | Type | Description |
|---|---|---|
d | Date | The date to convert. |
Returns
bigint
Whole Unix seconds since the epoch.
Example
const expiration = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000);const expirationTimestampSeconds = dateToEthereumTimestamp(expiration);