469,625 Members | 1,807 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

In date how to print year in words

hai everybody
i wants to know, in date how to print year in words using javascript. please help me.
Nov 14 '06 #1
1 1048
vee10
141 100+
hi,

i think u have to get the year from the date then place a switch case for example

case "7":
if(i==0)
str1="Seven Thousand"
else if(i==1)
str1=str1+" Seven hundred"
else if(i==3)
{
if(flag1==1) str1=str1+" Seventeen";
else
str1=str1+" Seven";
flag=0;
flag1=0;
}

else str1=str1+" Seventy";
break;

for each and every digit from 1 to 9 u should place the code with small change
flag represents that in the third place there is 0

for example 2007 u should get as two thousand six
and flag1 for 1 if 2017 u should get as two thousand seventeen

for 0 just make flag=1

case "0":
flag=1;
break;

and for 1 if it is in 3 position then make flag1=1

i hope u understood





hai everybody
i wants to know, in date how to print year in words using javascript. please help me.
Nov 14 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.