Skip to content
Advertisement

Get Year From Date string

I want to check whether the current year is greater than a date string(D-M-Y) here is my code

JavaScript

Advertisement

Answer

You can use strtotime():

JavaScript

UPDATE

Because you’re using an unconventional datestamp, you have to use different methods, eg:

JavaScript

NOTE: If you want to always be sure that your date gets correctly understood by strtotime, use YYYY-MM-DD

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement