如何根据客户端机器日期格式在javascript中格式化日期。 [英] How to format a date in javascript as per the client machine date formatting.

查看:81
本文介绍了如何根据客户端机器日期格式在javascript中格式化日期。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB脚本编码的网站,需要按照客户端计算机配置以格式显示日期(短日期)。

例如,如果客户端计算机配置为英语(英国)格式且短日期设置为 dMyy 然后系统日期显示为 13.10.16 。所以我希望我的网站也以这种格式显示日期。



请建议我完成这项工作。



谢谢



我尝试了什么:



我知道这不能在服务器端代码中完成,因为它将返回服务器样式格式化日期,因此尝试了一个javascript函数 .toLocaleDateString()但不幸的是,这会返回一个长格式的日期,我需要一个短格式的日期。

I am working on a website coded in VB-Script and need to show the Dates (Short-Date) in a format as per the Client machine configuration.
For Example if a client machine is configured to English(UK) format and short date is set as d.M.yy then the system date is shown as 13.10.16. So I want that my website also shows the date in this format.

Kindly suggest me some way to get this done.

Thanks

What I have tried:

I know this could not be done in server side code as it will return the server style formatted date and thus tried a javascript function .toLocaleDateString() but unfortunately this returns a date in long format and I need a date in short format.

推荐答案

请参阅 JavaScript日期参考 [ ^ ]。这些是用JavaScript获取日期的所有方法。



注意,如果需要,可以通过更改线程UI,然后生成,然后生成服务器日期。
See JavaScript Date Reference[^]. Those are all the ways to get your dates in JavaScript.

Note, you could it on the server if needed by changing the thread UI, for example, and then generating the date.


这篇关于如何根据客户端机器日期格式在javascript中格式化日期。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆