For every Laravel application birthday should be displayed as it was saved.
It should have a type 'date' and those 'created_at' should be 'datetime'
From New Zealand the record could be created Friday but for Cooks Island the record can be Thursday entry.
This is where PHP Carbon date comes to uses and Javascript Moments.
Install Moment and format as required. In VueJS create a filter
From New Zealand the record could be created Friday but for Cooks Island the record can be Thursday entry.
This is where PHP Carbon date comes to uses and Javascript Moments.
Install Moment and format as required. In VueJS create a filter
import moment from 'moment';
import moment from 'moment';
import {VueConstructor} from 'vue';
export const filters = {
period: (value: string): string => {
if (!value) return '-';
return moment(value).format('MMM YYYY');
},
periodFullMonth: (value: string): string => {
if (!value) return '-';
return moment(value).format('MMMM YYYY');
},
date: (value: string): string => {
if (!value) return '-';
return moment.utc(value).local().format('DD-MM-YYYY');
},
absoluteDate: (value: string): string => {
if (!value) return null;
return moment(value).format('DD-MM-YYYY');
},
};
export const createFilters = (vue: VueConstructor) => {
vue.filter('period', filters.period);
vue.filter('date', filters.date);
vue.filter('absoluteDate', filters.absoluteDate);
vue.filter('periodFullMonth', filters.periodFullMonth);
};
export default filters;
You might need to format the fields requests when saving
Model::create([
'began_at' => Carbon::createFromFormat('d-m-Y', $request->get('began_at')),
'terminated_at' => $request->get('terminated_at'),
]);
Database Migration Scripts
$table->dateTime('created_at');
$table->date('birthdate');