0

Possible Duplicate:
Managing date formats differences between PHP and MySQL

I am using jQuery ui datepicker

and initialized with following format

$("#task_date").datepicker({dateFormat : "m/d/y",
            showOn: "button",
            buttonImage: "<?= base_url(); ?>assets/img/calendar.png",
            buttonImageOnly: true
        });

so the date format is in "m/d/y" ,how can i convert it to mysql date format ?

also i need to convert from mysql date format to "m/d/y" ...

0

1 Answer 1

2

Change dateFormat : "m/d/y" to

dateFormat : "yy-mm-dd"    //Which is same as PHP's 'Y-m-d' or '2012-07-14'

And, for converting to m/d/y format(in jQuery), you'll need to do:

var date = $('#task_date').datepicker({ dateFormat: 'dd-mm-yy' }).val();

Date conversion(in jQuery and in PHP)

Sign up to request clarification or add additional context in comments.

2 Comments

this would save so much coding, +1
pardon me , but its requirement ..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.