Previous Article

PHP Time() Equivalent for Javascript

Next Article

This function utilises the Date object. When the Date.getTime() object instance is created it calls the number of seconds since 1 January 1970 UTC. As we only want the number of seconds (not milliseconds) we divide the result by 1000.

The Math.floor part rounds the number down to the nearest whole number.

function time() {
    var timestamp = Math.floor(new Date().getTime() / 1000)
    return timestamp;
}
Avatar of Clive Walkden

Clive Walkden

Posted:

Latest Articles

Linux command line tools, installations etc

Linux

How to Install NordLayer VPN Client on Ubuntu 20.04 and Connect to a Virtual Network

A simple to follow installation guide for NordLayer VPN

MySQL usage, tweaks and learnings

MySQL

Mastering MySQL Database Imports on Linux

Learn efficient ways to import MySQL databases on Linux using the mysql command-line client. Explore the --source option and < operator for seamless data migration. Master MySQL imports on Linux with our comprehensive guide.

DevOps principles and tool usage

DevOps

Mastering SSH Key Conversions for DevOps

A guide to convert SSH keys from one version to another using Linux CLI