Hello, I’m using the login extra and I’m creating a hook to save the dob on unix timestamp for the registration and update details pages.
Using jquery datepicker to select the date in human format 01-01-1999 <input class="datepicker" type="text" name="dob" id="dob" value="" />
Then on submit I need the hook to save the info in unix to be displayed right in the manager users area.
Have you checked the value directly in the database? If it’s a timestamp, MODX will usually convert it to a human-readable date when you retrieve it with a tag or in code, which might make you think it’s stored in the wrong format.
It appears that my earlier post was wrong. The dob field expects a unix timestamp.
If your JQuery datepicker gives you a human-readable date, you’ll have to call strtotime() on it before saving it in the dob field.
I think I would try to modify the result returned from your datepicker to turn it into a timestamp. This is one method. Since you know the format produced by the datepicker, though, you might be able to come up with something simpler.
Since you need a timestamp and the datepicker doesn’t give you one, I don’t see how using an extended field would help. To do that, you’d have to use PHP to get and write the extended fields array, and if you’re in PHP, why not just use strtotime() and put it in the DOB field?
The above will also change the field to be unix though (displayed on the front end). If you don’t want that I think you can use parseDate function. Store the date into a variable and throw it into parseDate.