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?

Recommended Answers

All 3 Replies

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

this worked for me.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.