Reputation: 29
I have:
var date = new Date();
and i have many formats:
var one = 'yy-mm-dd';
var two = 'dd.mm.yy';
var three = 'dd/mm/yy';
var four = 'mm/dd/yy';
Is possible to showing current date with this four formats? I know - i can use clause IF or SWITCH and set this, but maybe in JavaScript or jQuery without external libraries i can use this format as option?
Upvotes: 2
Views: 600
Reputation: 339985
If you're also already using jQuery UI, there's a string formatter function in the DatePicker
.
If not, use Datejs.
Upvotes: 1
Reputation: 11439
You will have to do it yourself by using getFullYear(), getMonth() and getDate() and combining them as you see fit (no jquery/jquery UI required).
If you are using or can use JQuery UI you can take advantage of the $.datepicker.formatDate method (that's the approach we took).
Your question has been asked (in a somehow different form) before
Upvotes: 0