Answers for "how to get timestamp"

8

java timestamp

Timestamp timestamp = new Timestamp(System.currentTimeMillis());
//2016-11-16 06:43:19.77
Copy
Posted by: Guest on April-12-2020
2

get current timestamp shell

// If you want to get unix timestamp, then you need to use:
timestamp=$(date +%s)
Posted by: Guest on September-09-2020
5

java timestamp

package com.mkyong.date;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeStampExample {

    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");

    public static void main(String[] args) {

        //method 1
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        System.out.println(timestamp);

        //method 2 - via Date
        Date date = new Date();
        System.out.println(new Timestamp(date.getTime()));

        //return number of milliseconds since January 1, 1970, 00:00:00 GMT
        System.out.println(timestamp.getTime());

        //format timestamp
        System.out.println(sdf.format(timestamp));
        
    }

}
Copy
Posted by: Guest on April-12-2020
3

how to get the timestamp in javascript

const currentTimeInSeconds=Math.floor(Date.now()/1000); //unix timestamp in seconds
Posted by: Guest on April-22-2020

Code answers related to "how to get timestamp"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language