Javascript has a lot of inbuilt methods you can use to get the date and time. The first thing you need to do is to create a new Date object:

var d = new Date();

Example to get the current date:


var d = new Date();


var d1=d.getDay();

var m=d.getMonth()+1;

var y=d.getFullYear();

document.write(“Today is “ + d1 + “/” +m + “/” +y);


Example – Age Calculator



Function age() {

Var byear =prompt(“enter Year of Birth ?”);

var d = new Date();

var y=d.getFullYear();

var q=y-byear;

alert(“You are  “+q + “ Years Old”);

}  </script>



<h2>Age Calculator Example </h2>

<input type=”button” value=”Calculate Age” onclick=”age()”>



Week Days Example – Switch Case


function viewday()


var d=new Date().getDay();



case 0:



case 1:



case 2:



case 3:



case 4:



case 5:









<input type=”button” value=”Get Day” onclick=” viewday()”>

author image

About admin

You Might Also Like...

javascript training
JavaScript – Advanced Learning
Data types in Mysql / Mariadb


  1. Hello there! Nice stuff, please keep me posted any time you post
    something just like this!

  2. Hi and thank you for the actual blog post ive recently been searching about this particular advice on-line for sum hours these days.
    many thanks.

  3. You have mentioned very attention-grabbing things. Thank you for sharing.

  4. Hello friend, This was a fantastic post for such a difficult topic to talk about.
    I look ahead to seeing a lot more superb posts like this one.

    Thank you.

  5. Keep up the wonderful piece of work, I read few posts
    on this site and I think that your web blog is truly
    attention-grabbing as well as has lots of outstanding information.

  6. I don’t know how I ended up here, however I thought this post was great.
    I do not know who you are but definitely you’re going to a famous blogger when you aren’t already
    Many thanks!

  7. I’ve been exploring for a while for top quality articles or blogs on this
    kind of area. Exploring in Yahoo I at last came across this site.
    Looking over this info made me discovered just what I wanted.
    I will visit your site frequently.

  8. If your friends are going set for golf art prints and pictures
    of tiger woodsand Arnold palmer have you thought to just decorate your
    living room with one of these prints which are certainly going to result in the
    modification that you desire within your lounge. , you could possibly anticipate to see a
    few prints being bid as much as hundreds and hundreds of pounds.
    Lots of folks flourish enough to pay money on nice vacations,
    an extra home, a pleasant car, and even theater tickets.

  9. Fascinating post. I’ll be sticking around to find out a lot more
    from you fellas. Thank you!

  10. Thanks a lot for sharing this great info! I’m excited to see more
    blog posts!

  11. I do trust all the concepts you’ve offered to your
    post. They’re really convincing and can certainly work.

    Still, the posts are too short for novices.
    May you please prolong them a bit from next time? Thanks for the post.

  12. Admiring the dedication you put into your website and in depth information you offer.
    It’s great to come across a blog every once in a
    while that isn’t the same old rehashed information. Wonderful read!
    I’ve saved your site and I’m adding your RSS feeds to my Google account.

  13. The savvier you then become in your facebook marketing – the greater income you may make.
    Therfe are dozens of seminars telling us thst “social is essential”
    to yoyr business. You can also go the “character” route to make the personaliity traits too much, like uskng “credit man” ffor
    the sub-prime car lot.

  14. Try ordering yur new asual dress or top online this season to see thee
    way you such as the process, you may well be completed
    wwith the mall forr good. Try to pick outfits determined by which colors
    and styles look great on you. This quality onl is
    sold with high standards over the entire manufacturing

Leave a Reply

Your email address will not be published.

Enjoy the tutorial? Please spread the word :)

Follow by Email