Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
I am trying to create a reminder page that will use a cron job to run the page every day and I am using the comment sections with a datepicker input to let the user pick when to be reminded via email.

At this point I am stuck trying to establish the equality between the current date and the user defined.
I did the following
Code: Select all
<cms:comments page_id=k_page_id order='desc'>
<cms:set scheduled = '<cms:show reminder_date />' />
<cms:set date = '<cms:date />' />

<cms:if scheduled == date >
   <p>Do something</p>
    <cms:else />
    <p>Noooot</p>
</cms:if>
</cms:comments>


And even though today is 24/11/2015 and I add in my datepicker the same day/month/year I get Noooot as a respose.

I believe it's a date format issue when trying to establish the equality..but I don't know how to go about it.
Alin,

First, one needs to use double-quotes while using Couch code as values. So the rectified code would be as follows -
Code: Select all
<cms:set scheduled = "<cms:show reminder_date />" />
<cms:set date = "<cms:date />" />

Second, try printing out both the dates and confirm that both have matching formats. Couch stores all dates internally in 'Y-m-d H:i:s' format. So, I think, you'll have to format <cms:date> to match it as follows -
Code: Select all
<cms:date format='Y-m-d H:i:s' />

Hope it helps.
KK wrote: Alin,

First, one needs to use double-quotes while using Couch code as values. So the rectified code would be as follows -
Code: Select all
<cms:set scheduled = "<cms:show reminder_date />" />
<cms:set date = "<cms:date />" />

Second, try printing out both the dates and confirm that both have matching formats. Couch stores all dates internally in 'Y-m-d H:i:s' format. So, I think, you'll have to format <cms:date> to match it as follows -
Code: Select all
<cms:date format='Y-m-d H:i:s' />

Hope it helps.


That's where I was going wrong, the double quotes...whenever choosing the format, I always put single quotes and got an error.

Also, is there a way of eliminating the time from the datepicker, at this point it's always 00:00:00. therefore and equality between that and the current time will be hard to achieve.
is there a way of eliminating the time from the datepicker, at this point it's always 00:00:00. therefore and equality between that and the current time will be hard to achieve.
I think it'd be easier to make the date being compared have its time component set to zero as follows -
Code: Select all
<cms:date format='Y-m-d 00:00:00' />

Does it help?
KK wrote:
is there a way of eliminating the time from the datepicker, at this point it's always 00:00:00. therefore and equality between that and the current time will be hard to achieve.
I think it'd be easier to make the date being compared have its time component set to zero as follows -
Code: Select all
<cms:date format='Y-m-d 00:00:00' />

Does it help?


Yes it does ^^ Thank you very much !!!
Have a great evening !
5 posts Page 1 of 1