|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
How to get Current year with javascript I want write a code where i can get the current year.I have asked about the same to my friends too they told me that it's possible with javascript but don't know what would be the code for the same.Anyone over here can provide me code for getting current year. |
#2
| |||
| |||
Re: Get Current year with javascript Try to use the following code for getting Current year by using javascript Code: <script type="text/javascript"> <!-- var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var d = new Date(); var curr_date = d.getDate(); var curr_month = d.getMonth(); var curr_year = d.getFullYear(); document.write(curr_date + "-" + m_names[curr_month] + "-" + curr_year); /* The last two lines above have to placed on a single line */ //--> </script> |
#3
| |||
| |||
Re: Print Current year with javascript If you want to get current year following are the code for the same Code: <script type="text/javascript"> var brn = new Date("July 21, 2009 01:17:00"); document.write("I was born in " + brn.getYear()); var da = new Date(); document.write(da.getYear()); </script> |
![]() |
|
Tags: current year, java, javascript |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help in finding the current day of the year in PHP | Karsenman | Software Development | 5 | 23-01-2010 10:14 AM |
Online threats for the current year | Aandaleeb | Networking & Security | 5 | 13-01-2010 12:22 AM |
How to write a program to determine if year is leap year or not | Luis-Fernando | Software Development | 4 | 30-11-2009 05:21 PM |
How to find out Current Page Url with the help of JavaScript? | Kushan | Software Development | 3 | 21-11-2009 10:40 AM |
How to get current directory | Scott2580 | Software Development | 3 | 11-10-2008 03:40 PM |