在JavaScript / Jquery中获取DD-Mon-YYY格式的当前日期 [英] Get current date in DD-Mon-YYY format in JavaScript/Jquery

查看:78
本文介绍了在JavaScript / Jquery中获取DD-Mon-YYY格式的当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在javascript中获取DD-Mon-YYYY的日期格式。
我曾问过问题,并将其标记为 jQuery日期格式化的重复

I need to get the date format as 'DD-Mon-YYYY' in javascript. I had asked a question, and it got marked duplicate to jQuery date formatting

但是,问题中提供的答案是以DD-MM-YYYY格式获取当前日期,而不是DD-MON-YYYY。
其次,我没有使用datepicker插件。

But, the answers provided in the question are to get the current date in "DD-MM-YYYY" format and not "DD-MON-YYYY". Secondly, I am not using datepicker plugin.

你可以帮助我,好像如何在DD-Mon-YYYY格式中获取当前日期。

Can you please help me as if how to get the current date in "DD-Mon-YYYY" format.

推荐答案

在DD-Mon-YYYY的JavaScript中没有native格式。您将不得不将其全部放在一起。

There is no native format in javascript for DD-Mon-YYYY. You will have to put it all together manually.

答案是从这个问题的灵感来源:
如何格式化JavaScript日期

The answer is inspired from this question: how to format javascript date

var m_names = new Array("Jan", "Feb", "Mar", 
"Apr", "May", "Jun", "Jul", "Aug", "Sep", 
"Oct", "Nov", "Dec");

var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
document.write(curr_date + "-" + m_names[curr_month] 
+ "-" + curr_year);

这篇关于在JavaScript / Jquery中获取DD-Mon-YYY格式的当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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