1

I have a member field [cb1_expire] that I am using to store the expiration date in the user profile. The format that will be put into the field will always be "mm/dd/yyyy". (field type is text) I want to compare this field with the current date to see if the current date is past the expiration date so that I can perform a specific action and inform the user that is access is expired. So far I have not been able to render the custom field in a format that I can test with the current date.

Is this possible and if so how can I accomplish this?

Any help greatly appreciated.

Anthony Jaxon, Los Angeles, CA USA

3
  • This may help too : expressionengine.stackexchange.com/q/37782/166 Jul 15, 2016 at 5:25
  • I've tried the following methods to get my custom field containing "01/23/1998" to any format I can use to compare with the current date. None of these methods work.
    – Anthony J
    Jul 15, 2016 at 5:48
  • {if "{cb1_expire format='%U'}" < "{current_time format='%U'}"} date has expired {/if}
    – Anthony J
    Jul 15, 2016 at 5:49

2 Answers 2

0

Hmm, If you cant convert your field to a date field, you're going to have build a plugin using php strtotime function or use something like this from Rye

0

I finally got it working by comparing the dates in a "yyyymmdd" format. The issue seems to be that custom member fields can only be set to text format and so I was never able to convert it to UNIX format. So I am entering the dates in the custom member field (cb1_expire) as 20151201. Then I format the current_time to the same format and then compare them.

{if '{current_time format='%Y%m%d'}' > cb1_expire}

If the formatted current_time is greater than cb1_expire, I know the expiration date has passed.

Hope this helps someone....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.