-
Jul 19th, 2012, 03:30 AM
#1
Thread Starter
Lively Member
Format the date
Hi all. I'm a javascript newbie and I'm stuck, so I've got some questions.
The first one is, I know you can store the date like this....
Code:
var mydate = new Date(2000, 11, 31);
But on the web page the person enters the date like this..... 31/12/2000. So is it possible to code it this way....
Code:
var mydate = new Date(31/12/2000);
I couldn't find anything on the internet, so maybe someone can offer some tips or help? Thanks.
-
Jul 19th, 2012, 03:51 AM
#2
Re: Format the date
You could try the datejs library. Link: http://code.google.com/p/datejs/
It allows various parsing and formatting ways. Check the sample usage section for more details.
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Jul 29th, 2012, 01:32 PM
#3
Hyperactive Member
Re: Format the date
Are you getting the date as one string? If so, you can split by the char '/' and have your date in an array.
Code:
var date = "31/12/2000";
var date_array = date.split("/");
var day = date_array[0];
var month = date_array[1];
var year = date_array[2];
For more info: http://www.w3schools.com/jsref/jsref_split.asp
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|