Jump to content

Simple converting dates help


gergy008

Recommended Posts

Hello everyone, I'm here again with moar problems  :-[.

 

This time I need help converting dates,

I have the jQuery UI Datepicker on my register form, Which creates a date with the format of 21/02/1995, Or "dd/mm/yyyy".

Can someone explain how convert this string to "yyyymmdd"?

 

Thanks in advance  :D

 

(Something tells me this will end up really simple.... Hmm......)

Link to comment
Share on other sites

The datepicker should be configurable to send the date in whatever format you want, at least if it's the same one I've used in the past.

 

But I need it also to be user friendly, So the datepicker creates dd/mm/yyyy but php converts it to yyyymmdd ;)

 

I'll try it like that PFMa, I didin't think it would work but I just didn't think about it right.

Link to comment
Share on other sites

Got it sorted, Adding tags for google search results and heres the code. Very simple :)

 

$dobs=explode("/", $dob);
$newdob=$dobs[2].$dobs[1].$dobs[0]."000000";
//converts 21/02/1995 into 19950221000000 so you can directly compare with other dates in the format date("ymdhis")

Link to comment
Share on other sites

The datepicker should be configurable to send the date in whatever format you want, at least if it's the same one I've used in the past.

 

Yup, that's exactly what I meant. The jQuery datepicker I've used has the display logic completely separate from the formatting logic, as it should be.

I'll try it like that PFMa, I didin't think it would work but I just didn't think about it right.

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.