Wednesday, March 7, 2018

Carbon – disable the default year setting - development

Carbon – disable the default year setting

as we all know, Carbon is setting the default year by the current year when we parse a date without specifying a year.

Is it possible to disable the “setting the default year” behavior when parsing a date?

Example

$myDate = Carbon::parse('dec 25');

myDate must return null when getting the year property.

$myDate->year; // MUST RETURN NULL;

Thanks for help.



from Laravel Questions and Answers https://laravelquestions.com/laravel/carbon-disable-the-default-year-setting/
via Lzo Media

No comments:

Post a Comment