Using filter_var() to verify date?

前端 未结 8 1288
Happy的楠姐
Happy的楠姐 2021-01-12 01:58

I\'m obviously not using filter_var() correctly. I need to check that the user has entered a valid date, in the form \"dd/mm/yyyy\".

This simply returns whatever I p

8条回答
  •  没有蜡笔的小新
    2021-01-12 02:35

    A simple and convenient way to verify the date in PHP is a strtotime function. You can validate the date with only one line:

    strtotime("bad 01/02/2012 bad"); //false
    strtotime("01/02/2012"); //1325455200 unix timestamp
    

提交回复
热议问题