UNIX_TIMESTAMP in SQL Server

If you’re not bothered about dates before 1970, or millisecond precision, just do: — SQL Server SELECT DATEDIFF(s, ‘1970-01-01 00:00:00′, DateField) Almost as simple as MySQL’s built-in function: — MySQL SELECT UNIX_TIMESTAMP(DateField); Other languages (Oracle, PostgreSQL, etc): How to get the current epoch time in … If you need millisecond precision (SQL Server 2016/13.x and … Read more

Joda DateTime to Unix DateTime

Any object that inherits from BaseDateTime (including DateTime) has the method public long getMillis() According to the API it: Gets the milliseconds of the datetime instant from the Java epoch of 1970-01-01T00:00:00Z. So a working example to get the seconds would simply be: new DateTime().getMillis() / 1000 For completeness, the definition of the Unix Timestamp … Read more

How do I get a Unix Timestamp in Clojure?

Pretty much all JVM-based timestamp mechanisms measure time as milliseconds since the epoch – so no, nothing standard** that will give seconds since epoch. Your function can be slightly simplified as: (quot (System/currentTimeMillis) 1000) ** Joda might have something like this, but pulling in a third-party library for this seems like overkill.