[RESOLVED]how to read the client system datetime format using javascript

Dear,

I want to read the user’s system datetime format with javascript

I have tried with all my possibilities but didn’t get any solution.

Please give me any solution.

Thank You

Regards

jagadeesh

 

 

Thank you for your reply,

But

It is not possible to read or get the user system datetime format?

Thank you

regards

jagadeesh

 

Yes, u dont really need to worry abt this (formatting based on web client’s culture),
Datejs takes care of everything.

Hi,

You can use javascript date function-

http://www.w3schools.com/js/js_obj_date.asp

try this:

<script type="text/javascript">
    
    function displayTime()
    {
        var localTime = new Date();
        var year= localTime.getYear();
        var month= localTime.getMonth() +1;
        var date = localTime.getDate();
        var hours = localTime .getHours();
        var minutes = localTime .getMinutes();
        var seconds = localTime .getSeconds();
        var div=document.getElementById("div1");
        div.innerText=year+"-"+month+"-"+date+" "+hours+":"+minutes+":"+seconds;
    }
    
    </script>

Then you can display it at web page.

 <body onload="displayTime();">
    <form id="form2" runat="server">
        <div id="div2"></div>
    </form>
</body>

more:

http://forums.asp.net/p/1247758/2303034.aspx

Hi,

You can try the rajsedhain’s code, in  order to acquire the same datetime format, you can also add some code in the script,

for example:  " if (month< 10)  month = "0" + month ; "

 

Hope it helps.

 

Leave a Reply