Jump to content

Changing the format of a date in $_POST


mdemetri2

Recommended Posts

Hi

I have a javascript calendar that populates a form field (survey) in the format of dd/mm/yyyy. I don't know of a method to change the format in the calendar. 

 

So, I would like the format to be changed at the point the form is submitted and the date is used to update a record. 

 

I have tried to amend the portion of the update script for the survey field to change the format as part of it submitting the change. I used this line: 

 

GetSQLValueString(date("Y-m-d, strtotime("$_POST['survey']), "text")

 

but I'm not getting the expected results, essentially from the text field entry format of dd/mm/yyyy I want Y-m-d

 

Is this possible?

 

Thanks in advance. 

 

 

Link to comment
Share on other sites

Look it up in the documentation for your particular datepicker. If there is none, use one that has.

 

http://api.jqueryui.com/datepicker/#option-dateFormat

 

PS: I prefer to set datepickers to use "31 Jan 2014" format as it is clear to the user, unambiguous and recognised by strtotime()

Edited by Barand
Link to comment
Share on other sites

Well, saying that you couldn't implement this is rather vague. What exactly is the problem?

 

Using DateTime to convert the format is a good solution and works perfectly fine. If you're not getting the expected result, you've made a mistake. But of course we can't help you with that unless you post your code and describe the specific problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.