strtotime PHP的奇怪响应

I have a code where I'm using strtotime() to get the date timestamp in PHP.

Have encountered a weird response of it.

Case 1. I got a date like "Tue Jul 2 6pm" : strtotime gives bool(false).

<?php $case1 = strtotime("Tue July 2 6pm"); 
var_dump($case1);
?>

Case 2. If the date is like "Tue Jul 2 6:00pm" :strtotime gives timestamp "1562115600" taking year as current year.

<?php $case2 = strtotime("Tue July 2 6:00pm"); 
var_dump($case2);
?>

Can anyone help me out. Why did strtotime gave bool(false) for the first case ?

What can be done to fix this, Please help ?

check php manual for strtotime:

The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC),

Returns a timestamp on success, FALSE otherwise.

To fix,it must be converted into a valid format

valid date time formats in php

To your first point:

<?php
date_create("Tue Jul 2 6pm");
var_dump(date_get_last_errors());

Gives an error: 'The timezone could not be found in the database'. Which means it is not recognized as a valid date/time string. You can explicitly specify the format:

date_create_from_format("D F j ga", "Tue Jul 2 6pm")