I'm trying to change this date format :
$date= date('Y-m-d H:i:s')
in to this :
Jan 5, 2100 23:50:00
to use it here :
var acountDownDate = new Date("<?php echo $date?>").getTime();
I'm trying to change this date format :
$date= date('Y-m-d H:i:s')
in to this :
Jan 5, 2100 23:50:00
to use it here :
var acountDownDate = new Date("<?php echo $date?>").getTime();
Simply do format like this,
<?php
$end = date('F j, Y H:i:s');
echo $end;
?>
DEMO: https://3v4l.org/GSBZY
I'm trying to change this date format...in to this...
Jan 5, 2100 23:50:00
...to use it here...
Don't do that. That string is not in any format that JavaScript's Date
object is supposed to parse.
Instead, use c
which provides an ISO-8601 string, which the Date
constructor supports.
$date= date('c')
Alternately, since what you want is the milliseconds Epoch value (number of milliseconds since midnight January 1st, 1970 GMT) (I can tell because you're using getTime()
on the JavaScript Date
), just output that directly rather than using Date
. If the milliseconds part isn't really important, use time
and multiply by 1000:
$date = time() * 1000
Then:
var acountDownDate = <?php echo $date?>;
If you want millisecond precision,