I need to get user client's date and convert it into PHP vars.
I know it's a bit hacky, but I am able to get the date from the user client into PHP
$today_js = '<script>document.write(new Date());</script>';
echo $today_js;
// Mon Oct 28 2019 12:12:20 GMT-0500 (Central Daylight Time)
So I was hoping to convert the string to manipulate further in PHP like this:
$today_js = '<script>document.write(new Date());</script>';
$userdate = strtotime($today_js);
$today_dt = getDate($userdate);
$year = $today_dt['year'];
$month = $today_dt['mon'];
$day = $today_dt['mday'];
However I'm not getting desired outcome. The year is 1970 and both month and date are 1.
The question is not about front- back-end coding. I am getting the following PHP string: "Mon Oct 28 2019 12:12:20 GMT-0500 (Central Daylight Time)" just need the rest of my PHP code to work with it.
What am I missing?