A non well formed numeric value encountered

2019-01-02 21:10发布

I have a form that passes two dates (start and finish) to a PHP script that will add those to a DB. I am having problems validating this. I keep getting the following errors

A non well formed numeric value encountered

This is when I use the following

date("d",$_GET['start_date']);

But when I use the strtotime() function as advised by many sites I get a unix timestamp date of 1/1/1970. Any ideas how I can get the correct date?

8条回答
其实,你不懂
2楼-- · 2019-01-02 21:46

Simply you can solve this issue using strtotime() function.

date("d",strtotime($_GET['start_date']));
查看更多
千与千寻千般痛.
3楼-- · 2019-01-02 21:49

This helped me a lot -

$new_date = date_format(date_create($old_date), 'Y-m-d');
查看更多
登录 后发表回答