/ jQuery

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

Latest Articles

Linux command line tools, installations etc

Linux

Terraform Installation

A quick installation guide for Terraform on Ubuntu 18.04

Bitcoin - Cryptocurrency not just for geeks

Bitcoin

RollerCoin Intro

An introduction to the RollerCoin site and how you can use it to mine your own coins

Magento 2 Blog Posts

Magento 2

Magento 2.4.x Writing to a Log File

How to log to information to a file in different Magento 2.4.x versions