Description: Provided a numbered Javascript date, this function will convert that date into a unix timestamp.
Parameters: convertToUnixTimestamp(numbered_js_date)Output Type: Number (Unix Timestamp)
Code Snippet:
const { convertToUnixTimestamp, convertToUnixTimestampAsync } = require('vuub')
function SynchronousUsage () {
// Option 1
var currentTime = new Date().getTime()
var convertedDate = convertToUnixTimestamp(currentTime)
console.log(convertedDate) // Output: 1639655680
//Option 2
var currentTime = Date.now()
var convertedDate = convertToUnixTimestamp(currentTime)
console.log(convertedDate) // Output: 1639655680
}
async function AsynchronousUsage () {
// Option 1
var currentTime = new Date().getTime()
var convertedDate = await convertToUnixTimestampAsync(currentTime)
console.log(convertedDate) // Output: 1639655680
// Option 2
var currentTime = Date.now()
var convertedDate = await convertToUnixTimestampAsync(currentTime)
console.log(convertedDate) // Output: 1639655680
}