954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

jquery date format

Hello
I want to change date format to insert date in mysql. I tried as below code

<script type="text/javascript">
	$(function() {
    $("#datepicker").formatDate('yyyy-mm-dd');
		$("#datepicker").datepicker();
	});
	</script>

but its not working form me. can anybody suggests me how to do it?

arctushar
Junior Poster in Training
66 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 
var date = $('#datepicker').datepicker({ dateFormat: 'yyyy-mm-dd' });
pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 
<script type="text/javascript">
	$(function() {
    $("#datepicker").datepicker();
    $("#datepicker").formatDate('yyyy-mm-dd');
	});
	</script>

this worked for me.

arctushar
Junior Poster in Training
66 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

I know it is kind of off topic, but check out this library:

http://plugins.jquery.com/project/fIsForFormat

It is the most useful thing I’ve found when it comes to Date formatting in JavaScript. Not only does it make formatting a piece of cake, but it has many other cool features as well!

I have no idea why it is listed as a jQuery plugin. I went through the code and couldn’t find any references to anything that looked like jQuery (or any other libraries for that matter.) I’ve used it standalone and it works just fine.

faulkj
Newbie Poster
3 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: