How do I get the Scala UTC timestamp in seconds since January 1st, 1970?
Use the getTime() method to get a UTC timestamp, e.g. new Date(). getTime() . The method returns the number of milliseconds since the Unix Epoch and always uses UTC for time representation. Calling the method from any time zone returns the same UTC timestamp.
By convention, meteorologists use just one time zone: Universal Time, Coordinated (UTC). They also use the twenty four hour clock (where 0000 = midnight UTC). The date/time stamp on each forecast image represents the time at which the forecast is valid, measured in UTC.
The UNIX timestamp is an integer that represents the number of seconds elapsed since January 1 1970. The timestamp in JavaScript is expressed in milliseconds.
Technically, no. Even though epoch time is the means elapsed seconds since 1/1/70 00:00:00 the real "GMT" (UTC) is not. UTC time needed to be changed a few times to take in to account the slowing speed of the rotating earth. As everybody wrote, most people use epoch at UTC.
Same way as you would in Java:
val timestamp: Long = System.currentTimeMillis / 1000
As of Java 8 it's possible to do so like so:
import java.time.Instant unixTimestamp : Long = Instant.now.getEpochSecond
Via micha's answer here: https://stackoverflow.com/a/24703573/577199
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With