DEV Community

Imran Hossain (Rubab)
Imran Hossain (Rubab)

Posted on • Updated on

Date Parse Issue Due to Hidden Character

I have recently encountered a bug where Carbon failed to parse any given date input from datepicker. This issue is generated after some package update in the project. This affected the code line given below.

Carbon::parse($request->fromDate)->format('Y-m-d H:i:s')

After debugging I found out that a special hidden character (u+202f) is being placed in date time data which should actually be a space.

A very quick solution for this kind of issue can be checking and replacing this type of hidden character.

You can also use regular expression to allow only alphanumeric, space and some special characters to solve this issue.


Thank you for reading my article. You can join code with rubab for web development-related queries & discussions.

Also, you can find me on:

Linkedin For Regular Posts

My website

My Facebook Page

My Youtube Channel

Top comments (0)