Formatting Timestamps in Laravel and OctoberCMS

If you create a table with timestamp() via a migration, you'll actually get a timestamp that is matching the one created by date('Y-m-d H:i:s').

So in order to get the output correctly displayed with your local time format, or you'd like to format it and have an input to the database, then you'll need to format it before the output:

Created on: {{ date('F d, Y', strtotime($list->created_at)) }}

For formatting the input, eg. format a DOB datetime input:

$data = post();

$data['dob'] = date('Y-m-d H:i:s', post('dob'));

reference:  http://www.easylaravelbook.com/blog/2015/02/11/formatting-timestamps-in-laravel/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.