php - How to echo alert todays date using javascript? -


echo '<script>alert('.date('y-m-d h:i:s').')</script>'; 

i beginner , ask how possible me alert current datetime. tried above code not working.

i take date php var breaking out of single quote echo, if string, js needs surrounded in quotes.

try this:

echo '<script>alert("'.date('y-m-d h:i:s').'")</script>'; 

note double quotes echoed out around date string


Comments