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.
Hello bob.
I’m trying to read and save the dob (date of birth) for users on registration and edit profile sections.
In the profile page (Manager Manage/Users) the date format is: 01/15/1988 for Jan 15 1988
If I try to save this format 01/15/1988 using jquery datepicker on registration or update profile, the date on the user manager page always is 01/01/1970. That means the date is not being saved right.
If I have a date already saved in the manager area and use the placeholder to display the dob: [[!+dob]]
it return the unix format, for example: 116809200
If I save the dob from one of the forms in unix format it works fine and save the right date.
That is the reason why I’m trying to modify the field date between validation and send.
In my mind I take the value, convert it to unix and save it should work fine.
and if I need to display it I only use the placeholder like this: [[!+dob:date=%d-%m-%Y]]
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.
Yes mate I use it before, the problem was that it display the date in unix time, I even use normal time in one field and unix time in a hidden field, but at the end all that wasn’t necessary.