emmaspeedy Posted April 13, 2015 Share Posted April 13, 2015 HI, I have a little question for you guys. I want to display de date thanks to Javascrip. I can display it but !!! it display this --> 2015313 and i want this --> 2015/3/13 how can introduce the " / ". I have try everything but nothing seems to work. Here is that I have now : <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script type="text/javascript"> function InstallHeader( NomPage ) { document.getElementById("Entête").innerHTML=NomPage; } function InstallDate( ) { var a = new Date().getFullYear(); var m = new Date().getMonth(); var j = new Date().getDate(); document.getElementById("Date").innerHTML+=a; document.getElementById("Date").innerHTML+=m; document.getElementById("Date").innerHTML+=j; } </script> <style> #Entête { padding-left:2%; background-color:lightgray; width:85%; float:left; } #Date { background-color:lightblue; width:13%; float:left; text-align:center; } </style> </head> <body> <div id="Entête"> </div> <div id="Date"> </div> <script type="text/javascript"> InstallHeader("Titre de la page"); InstallDate();</script> </body> </html> Link to comment Share on other sites More sharing options...
justsomeguy Posted April 13, 2015 Share Posted April 13, 2015 I have try everythingI seriously doubt that.This is where you write the text:document.getElementById("Date").innerHTML+=a;document.getElementById("Date").innerHTML+=m;document.getElementById("Date").innerHTML+=j;You can add any additional text you want there. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now