Issue
I have an .sh script on my Linux server.
I need the date in milliseconds in Java, but everything I find on the net is giving me Unix Timestamp.
Like this: date=$(date -d 'today 00:00:00' "+%s")
I need java milliseconds, like here: https://www.fileformat.info/tip/java/date2millis.htm.
How do I get that easily without writing a long java code? There has to be an easy solution.
Solution
It's just unix epoch in milliseconds instead of seconds, so simply replace +%s
with +%s%3N
.
epoch_milli=$( date -d 'today 00:00:00' +%s%3N )
$ date +%s; date +%s%3N
1666798614
1666798614357
Answered By - ikegami Answer Checked By - David Marino (WPSolving Volunteer)