birthdate field from Ning backup

White Agency
White Agency
@white-agency
9 years ago
204 posts
There is a birthdate field that comes across from Ning in the format yyyy-mm-dd

If I set this field up using the form designer and set it to use the date type it doesn't pick up the date because it's in the wrong format.

Could the import correct the format or the date type allow the yyyy-mm-dd format ?
updated by @white-agency: 08/07/15 04:18:57PM
paul
@paul
9 years ago
4,331 posts
The problem is that in Jamroom, all dates are stored in unixtime format which only goes back to 1-1-1970 so is not suitable for storing birthdays so when developing the NingImport module I just saved the birthday field 'as is' in text format, thinking that I'd look at it again if and when the issue was raised, which is now lol
The date could be split and saved as three fields, user_birth_year/month/day but that is a bit clunky. Do you have any suggestions?
Thanks


--
Paul Asher - JR Developer and System Import Specialist
White Agency
White Agency
@white-agency
9 years ago
204 posts
That is a problem !!

Have a look at the answer here :- http://stackoverflow.com/questions/2788571/converting-a-date-string-which-is-before-1970-into-a-timestamp-in-mysql

and a link in the answer :- http://www.onlineconversion.com/unix_time.htm

Seems to suggest you can have dates before 1970

For the time being I've put a date validation on the filed so at least the user is forced to input a valid date.
paul
@paul
9 years ago
4,331 posts
I'm not sure if JR can handle negative unixtime, and even if it did, with the current date field calendar entry system a user would have to click the previous month button hundreds of times to get back to pre 1970!!
I wonder if the answer might be using some of the php date functions as modifiers on the field as is in the template(s).
Let me check that out.


--
Paul Asher - JR Developer and System Import Specialist
paul
@paul
9 years ago
4,331 posts
Try this in the user template where you want to show their birthdate -

{$_user.user_birthdate|strtotime|date_format:"%d %b %Y"}

and keep the field as a text field in the user update form.


--
Paul Asher - JR Developer and System Import Specialist

Tags