Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Thread Tools Search this Thread
Old 22-05-2009
Join Date: May 2009
Posts: 51
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.
Reply With Quote
Old 22-05-2009
Join Date: Apr 2008
Posts: 2,001
Re: Get Current year with javascript

Try to use the following code for getting Current year by using javascript

<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 */

Reply With Quote
Old 22-05-2009
Join Date: Feb 2008
Posts: 1,848
Re: Print Current year with javascript

If you want to get current year following are the code for the same
<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();

Reply With Quote

  TechArena Community > Software > Software Development
Tags: , ,

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads for: "How to get Current year with javascript"
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

All times are GMT +5.5. The time now is 04:23 AM.