Js does not have a function similar to php's time () function class to directly obtain unix timestamp timestamps. Therefore, it is inconvenient for some numbers that need to be generated at random time, the following is a function that is similar to getting unix timestamps in php.
Var time = Math. round (new Date (). getTime ()/1000 );
Explain the code below:
New Date () initializes a Date and time object
Get. Time () is divided by 1000 because it takes milliseconds.
Math. round rounds the value to the nearest integer or the specified number of decimal places, which is similar to php's ceil function.
Articles you may be interested in
- Mysql converts unix timestamp to date format, and MySQL queries the current time
- Conversion of date and unix timestamps in php and mysql
- How to verify the validity of date and time using javascript
- When CuteFTP is connected to the ftp server, the "invalid Parameters" error is displayed.
- How to obtain information about the Year, Zodiac, and constellation of the rule by using the date or timestamp in php
- Analysis of js setInterval and setTimeout usage
- How to set the jump wait time for the thinkphp page Jump (successerror)
- Php obtains the start time and end time timestamp of the week of the specified date.