DEV Community

Imran Hossain (Rubab)
Imran Hossain (Rubab)

Posted on • Edited on

1

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

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay