hi
we r deveolping a website in which users from different countries visit the site.we want to get time of user's country. our server is lloacated in US and it give time of us when we use datetime.now() in code behind.
if we use javascript for client side execution, it will rertun the machine time which user is using. we want to get local county's standard time.
can anyone help me. it is too much, i searched a lot on google but no result...........
Loading
Muhammad younasPosted Sep 20, 2012, 5:59 AM
Muhammad younasPosted Sep 20, 2012, 3:36 AM
function returnString() { debugger; var currentTime = new Date() var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear() var hour=currentTime.getHours() var mint=currentTime.getMinutes() if(mint<9) { mint="0"+mint } if(month<9) { month="0"+month } if(hour > 11){ var a= ("PM") } else { a=("AM") } document.getElementById("hdnResultValue").value = (day + "-" + month + "-" + year + "-" + hour + "-" + mint+ " "+a ); }
and in then at submit button i called returnstring() function
onclientclick and in page load i get hidenfield value it gives positive result.
But, i wrote this code in a test page that page is without masterpage, when i used this code in a page which is using master page, hiddenfield is not returning any value. i dont understand why this problm is occuring, may b due to masterpage.......... can u sugest any thing?
Mahesh ChandPosted Sep 15, 2012, 10:11 AM
http://weblogs.asp.net/mikebosch/archive/2007/11/15/getting-the-client-browsers-date-and-time-with-asp-net.aspx
Please share your code after it works!