Displaying Date with format

We can display the present day of the week by using getDay function of the JavaScript date object. Here getDay function will return 0 to 6 based on the day. Number 0 will be returned for Sunday and 1 for Monday.

We will create one day array with all the names of the seven days will be stored. Based on the value returned by getDay function the name of the day will be displayed from the array.

Here is the demo of the getDay function.


Here is the full code of the above demo.

<html>
<head>
<title>(Type a title for your page here)</title>
<script type="text/javascript">
function show_now(){
var my_day=new Date()
//var dt = new Date(\"Aug 16, 2005 05:55:00\");

var day_name=new Array(7); day_name[0]='Sunday' day_name[1]=' Monday' day_name[2]='Tuesday' day_name[3]='Wednesday' day_name[4]='Thursday' day_name[5]='Friday' day_name[6]='Saturday'
alert ("Today Day is = " + day_name[my_day.getDay()]); } </script></head> <body> <input type=button value="Show Day" onclick="show_now();"> </body> </html>

Date Project on getting Second Saturday of the month

Date Project on getting week day

User can enter any date in mm/dd/yy format and get the day of the week for that date.
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com




    balaji

    04-03-2013

    hai, i need that, if i give my date of birth in recent year like(12/12/2012) then i get the day of the date inwhich year i born..........
    smo

    09-04-2013

    This part is added now. Link is there at the end of this tutorial.

    Post your comments , suggestion , error , requirements etc here .




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer