Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Abhijeet Das
Abhijeet Das
Courses Plus Student 3,158 Points

can i embed current date,month and year, with current page number in javascript?

Hello friends, can i embed current date,month and year, with current page number of total pages in javascript? kindly help me with a code snippet, because i have no experience on javascript. Is there any solution with CSS? Thanks.

1 Answer

Lionel Sellam
Lionel Sellam
8,683 Points

Hey man,

Well, Treehouse taught me that when I'm having a difficulty, I have to check the documentation. So if you follow the link below, you'll get the date instance documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

If you read and scroll down to the examples, you'll see code snippets that you can easily take and implement in your own javascript.

Which will be something like that:

<script type="text/javascript"> var currentDate = new Date(); var day = currentDate.getDate(); var month = currentDate.getMonth() + 1; var year = currentDate.getFullYear(); document.write("<b>" + day + "/" + month + "/" + year + "</b>"); </script>

This will give a date on this format: 21/7/2015

Hope this helps,