2
votes

In my applications I use two libraries - Node.js and Laravel - which both interact with the same MySQL database tables to modify, insert and delete various data. Since my schema is created by Laravel migrations (which allow for timestamps), I wanted my Node.js application to also replicate the updated_at and created_at fields Eloquent uses. However, I realized I didn't know the format of the timestamps. So, the question was:

What is the format of Laravel's Eloquent timestamps?

1

1 Answers

4
votes

Laravel's Eloquent ORM actually uses MySQL's timestamp data type for formatting and storing the data. The format for these timestamps follows the following format, as specified by the MySQL documentation:

MySQL retrieves and displays...values in 'YYYY-MM-DD HH:MM:SS' format.

Also according to their docs:

TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

In example, a date of around when this question was asked - October 12, 2014 (8:15 PM) would be formatted like 2014-10-12 21:15:34. Recognize that single digit numbers have a zero digit in front of them, as the formatting specifies two digits for each value (except for years, which has four).