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

narenj

Member
كسي كد جاوا براي تبديل تاريخ ميلادي به شمسي را داره؟

ممنون ميشم اگر كمك كنيد

با تشكر
 

m_irani

New Member
سلام
شايد اين بدردت بخوره
HTML:
<html dir="rtl">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>New Page 1</title>
<script>

function funDate()  
{ 
		var date = new Date(); 

		var hours = date.getHours();
		var H = ((hours < 3)  ? "شب عاشقان بيدل چه شبي دراز باشد": 		 	   	  
		(hours < 5)  ? "سحرخيز باش تا کام روا باشي": 				  
		(hours < 9) ? "صبح بخير ايــران  Good morning": 				 
		((hours < 12) ? "روز بخير  Good day": 				 
		((hours < 15) ? "ظهر شما بخير  Good noon": 				 
		((hours < 20) ? "عصر شما بخير  Good afternoon": 				 
		((hours < 21) ? "غروب  Good evening": 				  
		(hours < 23) ? "شب شما بخير  Good night": 				  		   	   	 
		"شب شما بخير  Good night"))))) 		 

weekFa = new Array("يكشنبه","دوشنبه","سه‌شنبه","چهارشنبه","پنجشنبه","جمعه","شنبه");
monthsFa = new Array("فروردين","ارديبهشت","خرداد","تير","مرداد","شهريور","مهر","آبان","آذر","دي","بهمن","اسفند"); 

		 d = date.getDay();
		 dayFa = date.getDate();
		 monthFa = date.getMonth() + 1;
		 yearEn = date.getYear();
//Farsi
		 yearEn -= ( (monthFa < 3) || ((monthFa == 3) && (dayFa < 21)) )? 622 : 621;
		 switch (monthFa) {
        case 1: (dayFa <21) ? (monthFa =10, dayFa +=10): (monthFa =11, dayFa -= 20);
        break;
        case 2: (dayFa <20) ? (monthFa =11, dayFa +=11): (monthFa =12, dayFa -= 19);
        break;
        case 3: (dayFa <21) ? (monthFa =12, dayFa +=9) : (monthFa =1, dayFa -= 20);
        break;
        case 4: (dayFa <21) ? (monthFa =1, dayFa +=11): (monthFa =2, dayFa -= 20);
        break;
        case 5:
        case 6: (dayFa <22) ? (monthFa -=3, dayFa +=10): (monthFa -=2, dayFa -= 21);
        break;
        case 7:
        case 8:
        case 9: (dayFa <23) ? (monthFa -=3, dayFa +=9) : (monthFa -=2, dayFa -= 22);
        break;
        case 10:(dayFa <23) ? (monthFa =7, dayFa +=8) : (monthFa =8, dayFa -= 22);
        break;
        case 11:
        case 12:(dayFa <22) ? (monthFa -=3, dayFa +=9) : (monthFa -=2, dayFa -= 21);
        break;
        default: break;
		 }

		if (weekFa [d] == "شنبه") { 			
			tdDate.innerHTML = (H + '<br><b>' + "هفته نو مبارك " + '</b><p align="center"><font color="#008000">' + weekFa [d] + "، " + [dayFa] + " "  + monthsFa [monthFa - 1] + "، " + yearEn); 		
		} 		
		else{ 		
			tdDate.innerHTML = (H + '<p align="center"><font color="#008000">' + weekFa [d] + "، " + [dayFa] + " " + monthsFa [monthFa - 1] + "، " + yearEn);		 		
		} 
}

</script>
</head>

<body onload=funDate()>

<table border="1" width="100%">
	<tr>
		<td id=tdDate>&nbsp;</td>
	</tr>

</table>
</body>

</html>
 
آخرین ویرایش:

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

بالا