تبدیل تاریخ میلادی به شمسی

nevisande

Active Member
آقا سلام
میخواستم ببینم چطور باید تاریخ میلادی زیر رو به شمسی تبدیل کنم؟

کد:
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("ژانویه","فوریه","مارس","آوریل","می","ژوئن","جولای","آگوست","سپتامبر","اکتبر","نوامبر","دسامبر")
function getthedate()
{
    var mydate=new Date()
    var year=mydate.getYear()
    if (year < 1000)
        year+=1900
    
    var day=mydate.getDay()
    var month=mydate.getMonth()
    var daym=mydate.getDate()
    if (daym<10)
        daym="0"+daym
    
    var hours=mydate.getHours()
    var minutes=mydate.getMinutes()
    var seconds=mydate.getSeconds()
    var dn=""
    
    
    {
         d = new Date();
         Time24H = new Date();
         Time24H.setTime(d.getTime() + (d.getTimezoneOffset()*60000) + 3600000);
         InternetTime = Math.round((Time24H.getHours()*60+Time24H.getMinutes()) / 1.44);
         if (InternetTime < 10) InternetTime = "00"+InternetTime;
         else if (InternetTime < 100) InternetTime = "0"+InternetTime;
    }
    if (hours==0)
        hours=12
    if (minutes<=9)
        minutes="0"+minutes
    if (seconds<=9)
        seconds="0"+seconds
    //change font size here
    var cdate=daym+" "+montharray[month]+"  "+year+" | "+hours+":"+minutes+":"+seconds+" "+dn+"" | "y"
    if (document.all)
        document.all.clock.innerHTML=cdate
    else if (document.getElementById)
        document.getElementById("clock").innerHTML=cdate
    else
        document.write(cdate)
    }

    if (!document.all&&!document.getElementById)
    getthedate()

function goforit()
{
    if (document.all||document.getElementById)
        setInterval("getthedate()",1000)
}
window.onload=goforit

لطفا یکی کمک کنه
 

no.love

Member
سلام دوست عزیز
کد:
<SCRIPT LANGUAGE="JAVASCRIPT"> 
function showdate() { 
week= new Array("يكشنبه","دوشنبه","سه شنبه","چهارشنبه","پنجشنبه","جمعه","شنبه") 
months = new Array("فروردين","ارديبهشت","خرداد","تير","مرداد","شهريور","7","آبان","آذر","دي","بهمن","اسفند"); 
a = new Date(); 
d= a.getDay(); 
day= a.getDate(); 
month = a.getMonth()+1; 
year= a.getYear(); 
if (year== 0){year=2000;} 
if (year<100){year +=1900;} 
y=1; 
for(i=0;i<3000;i+=4) { 
if (year==i) {y=2;} 
} 
for(i=1;i<3000;i+=4) { 
if (year==i) {y=3;} 
} 
if (y==1) { 
year -= ( (month < 3) || ((month == 3) && (day < 21)) )? 622:621; 
switch (month) { 
case 1: (day<21)? (month=10, day+=10):(month=11, day-=20); break; 
case 2: (day<20)? (month=11, day+=11):(month=12, day-=19); break; 
case 3: (day<21)? (month=12, day+=9):(month=1, day-=20); break; 
case 4: (day<21)? (month=1, day+=11):(month=2, day-=20); break; 
case 5: 
case 6: (day<22)? (month-=3, day+=10):(month-=2, day-=21); break; 
case 7: 
case 8: 
case 9: (day<23)? (month-=3, day+=9):(month-=2, day-=22); break; 
case 10:(day<23)? (month=7, day+=8):(month=8, day-=22); break; 
case 11: 
case 12:(day<22)? (month-=3, day+=9):(month-=2, day-=21); break; 
default: break; 
} 
} 
if (y==2) { 
year -= ( (month < 3) || ((month == 3) && (day < 20)) )? 622:621; 

switch (month) { 
case 1: (day<21)? (month=10, day+=10):(month=11, day-=20); break; 
case 2: (day<20)? (month=11, day+=11):(month=12, day-=19); break; 
case 3: (day<20)? (month=12, day+=10):(month=1, day-=19); break; 
case 4: (day<20)? (month=1, day+=12):(month=2, day-=19); break; 
case 5: (day<21)? (month=2, day+=11):(month=3, day-=20); break; 
case 6: (day<21)? (month=3, day+=11):(month=4, day-=20); break; 
case 7: (day<22)? (month=4, day+=10):(month=5, day-=21); break; 
case 8: (day<22)? (month=5, day+=10):(month=6, day-=21); break; 
case 9: (day<22)? (month=6, day+=10):(month=7, day-=21); break; 
case 10:(day<22)? (month=7, day+=9):(month=8, day-=21); break; 
case 11:(day<21)? (month=8, day+=10):(month=9, day-=20); break; 
case 12:(day<21)? (month=9, day+=10):(month=10, day-=20); break; 
default: break; 
} 
} 
if (y==3) { 
year -= ( (month < 3) || ((month == 3) && (day < 21)) )? 622:621; 

switch (month) { 
case 1: (day<20)? (month=10, day+=11):(month=11, day-=19); break; 
case 2: (day<19)? (month=11, day+=12):(month=12, day-=18); break; 
case 3: (day<21)? (month=12, day+=10):(month=1, day-=20); break; 
case 4: (day<21)? (month=1, day+=11):(month=2, day-=20); break; 
case 5: 
case 6: (day<22)? (month-=3, day+=10):(month-=2, day-=21); break; 
case 7: 
case 8: 
case 9: (day<23)? (month-=3, day+=9):(month-=2, day-=22); break; 
case 10:(day<23)? (month=7, day+=8):(month=8, day-=22); break; 
case 11: 
case 12:(day<22)? (month-=3, day+=9):(month-=2, day-=21); break; 
default: break; 
} 
} 
document.write(day+"/"+months[month-1]+"/"+ year); 
} 
</SCRIPT>
<SCRIPT>showdate()</SCRIPT>
 

جدیدترین ارسال ها

بالا