Formatting an SQL timestamp with PHP

The date function expects an UNIX timestamp as its second parameter — which means you have to convert the date you get from the DB to an UNIX timestamp, which can be done using strtotime : $db = ‘2010-02-20 13:14:09′; $timestamp = strtotime($db); echo date(“m-d-Y”, $timestamp); And you’ll get : 02-20-2010 You were passing the … Read more

Cassandra cqlsh – how to show microseconds/milliseconds for timestamp columns?

In an effort to answer your questions, I did a little digging on this one. Does Cassandra capture microseconds with timestamp data type? Microseconds no, milliseconds yes. If I create your table, insert a row, and try to query it by the truncated time, it doesn’t work: aploetz@cqlsh:stackoverflow> INSERT INTO data (datetime, id, type, data) … Read more

MySQL column type “TIMESTAMP” implicitly includes “NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP”

In MySQL 5.6.5 there are several updates regarding this initialization, you can see on this link (Automatic Timestamp Properties Before MySQL 5.6.5). If you’re using MySQL <= 5.6.5, in order to ignore this initialization you need to set the DEFAULT value to 0 or NULL with NULL allowed. CREATE TABLE tbl ( field1 TIMESTAMP DEFAULT … Read more

Why do timestamps have a limit to 2038?

The limit is imposed by the 4 byte signed integers that most C libraries use for representing that count. Quick math (assumes 365 day years, not exactly correct): 2147483648 seconds ~ 68.1 years This also implies a lower limit of ~1900. Some libraries have started to introduce 64 bit epoch counts, but they are few … Read more

Using MySQL’s TIMESTAMP vs storing timestamps directly

Arguments for TIMESTAMP It implicitly stores data in UTC time zone. No matter what your session time-zone is. Useful if you need to use different time zones. You can have automated timestamping columns using DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP (one column per table only until MySQL 5.6.5) You can use datetime function for date … Read more

How to make elasticsearch add the timestamp field to every document in all indices?

Elasticsearch used to support automatically adding timestamps to documents being indexed, but deprecated this feature in 2.0.0 From the version 5.5 documentation: The _timestamp and _ttl fields were deprecated and are now removed. As a replacement for _timestamp, you should populate a regular date field with the current timestamp on application side.