The main issue: I gather the initial parameter in the datetime format, and use php date function to convert it to a readable format. From this format, I need to convert the date back to the same datetime parameter using javascript.
I have tried the getTime()
function in javascript to get a datetime parameter conversion.
<?php
$_REQUEST['date'] = 1500786000;
$date=date('Y-m-d', $_REQUEST['date']);
echo "<span id='date'>$date</span>";
?>
<script>
var pdate=new Date('#date').val().replace(/-/,'\/'));
console.log(pdate.getTime());
</script>
The original datetime parameter starts as 1500786000, is formatted as 2017-02-23 via PHP. The javascript conversion is 1500786000000, three 0s off from the expected format.
I would prefer not to use an alternative library, so anything that can be used in native javascript would be most helpful.