Today I have been playing around with mckoi database. In MySQL, there’s a NOW() function. This function simply returns the current timestamp. However, mckoi doesn’t have this function but I need it! This is what I did to get the current timestamp:

SELECT DATEFORMAT(DATEOB(), ‘yyyy-mm-dd HH:mm:ss’)

Just to be a little bit more paranoid, I set this function as a default value for my timestamp column, when I created a database. This is the syntax that I’m using:

CREATE TABLE myTable (

myTimestampColumn timestamp DEFAULT DATEFORMAT(DATEOB(), ‘yyyy-mm-dd HH:mm:ss’) not null
)

This is very helpful because during insertion, there’s no need to put an extra effort to manage myTimestampColumn. Everything is done automatically.



No Responses Yet to “Get current timestamp with mckoi”  

  1. No Comments Yet

Leave a Reply