是否可以使用java脚本找到系统日期时间格式 [英] is it possible to find the system date time format using java script
本文介绍了是否可以使用java脚本找到系统日期时间格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨专家,
有没有办法知道系统日期是dd / mm / yyyy或mm / dd / yyyy格式
使用java脚本?
提前感谢
(keerthi Kumar)
解决方案
如果你是使用jQuery,然后尝试以下代码,它将为您提供系统日期。
< span id =clientSyatemDate>这是JQuery当前的本地日期时间>< /跨度>
< button type =buttononclick =ClientSystemDate()> GetDate< / button>
脚本代码:
< script < span class =code-keyword>>
function ClientSystemDate(){
var todaydate = new Date();
var localdate =(todaydate.getMonth()+ 1)+'/'+ todaydate.getDate()+'/'+ todaydate.getFullYear();
alert(
('#clientSyatemDate')。text(localdate));
}
< / script >
<%@ Page 语言 = C# AutoEventWireup = true CodeBehind = WebForm1.aspx.cs 继承 = javascript.WebForm1 %>
<%@ 导入 命名空间 = System.Globalization %>
< !DOCTYPE html < span class =code-attribute> PUBLIC - // W3C // DTD XHTML 1.0 Transitional // EN http://www.w3.org/TR/xhtml1 /DTD/xhtml1-transitional.dtd\">
< html xmlns = http://www.w3.org/1999/xhtml >
< head >
< script type = text / javascript >
function show(){
var cultureInfo = <%= CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToString()%>;
alert(cultureInfo);
}
< / 脚本 >
< / head >
< body onload = show() >
< 表格 id = form1 runat = server >
< div >
< asp:Label ID = lblDate runat = server > < span class =code-keyword>< / asp:Label >
< / div >
< / form >
< / body >
< / html > 跨度>
hi experts,
Is there any way to know the system date is in dd/mm/yyyy or mm/dd/yyyy format
using java script?
thanks in advance
(keerthi Kumar)
解决方案
If you are usin jQuery then try the following code it will give you system date.
<span id="clientSyatemDate">This is current local Date Time in JQuery></span> <button type="button" onclick="ClientSystemDate()">GetDate</button>
Script Code:
<script> function ClientSystemDate() { var todaydate = new Date(); var localdate = (todaydate.getMonth() + 1) + '/' + todaydate.getDate() + '/' + todaydate.getFullYear(); alert(
('#clientSyatemDate').text(localdate)); } </script>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="javascript.WebForm1" %> <%@ Import Namespace="System.Globalization" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head > <script type="text/javascript"> function show() { var cultureInfo = "<%= CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToString() %>"; alert(cultureInfo); } </script> </head> <body onload="show()"> <form id="form1" runat="server"> <div> <asp:Label ID="lblDate" runat="server" ></asp:Label> </div> </form> </body> </html>
这篇关于是否可以使用java脚本找到系统日期时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文