I am using the following code to display the date in the front-end screen:
<h4> Date :
<script language="JavaScript">
date=Date()
document.write(date)
</script>
</h4>
Here h4 is the tag in CSS.
Here is the code for h4 in CSS file:
It is displaying the date in local machine. But when I deployed the project to the server machine it is not working.
Javascript runs on the client machine (on the browser).
new Date()in javascript gives the date from the client’s machine.To get the date from the server side, you need to pass the date from the server to the client. How you do this depends on the server side technology.
In JSP it would be something like:
And in PHP: