How to Insert custom date into mysql timestamp field?
The problem is that your field is defined as TIMESTAMP but UNIX_TIMESTAMP returns an int. Use INSERT INTO test VALUES (‘2013-08-05 18:19:03’ ) instead.
The problem is that your field is defined as TIMESTAMP but UNIX_TIMESTAMP returns an int. Use INSERT INTO test VALUES (‘2013-08-05 18:19:03’ ) instead.
Because Javascript uses milliseconds internally, while normal UNIX timestamps are usually in seconds.
Use the valueOf method on a moment object: For local time: moment().valueOf(); For UTC: moment().utc().valueOf();
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
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
The different values you stated are caused by mixing up the 1970 to 1980 offset with leap seconds. The correct offset value is 315964800 seconds. Explanation: UTC and GPS time deviate (on average) every 18 months by one additional second. This is called a leap second, introduced in UTC time base, necessary to adjust for … Read more
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.