Solution:
This code help you.
$messages = array('How are you today?', 'Perfect day for flying, isnt it?', 'You have flown last on '.$lastflown.'.', 'The time is <script> document.write(new Date().toString());</script>');
$key = array_rand($messages);
<?php echo $messages[$key]; ?>
You need surround your JavaScript code with tags. To show JavaScript output use document.write() function.
This string 'The time is <script> document.write(new Date().toString());</script>'
will be show like The time is Wed Oct 21 2015 17:18:32 GMT+0300 (MSK)
in browser.