Seite 1 von 1

Compare dates

Verfasst: Mi 8. Apr 2015, 10:02
von ounos
Hey,

I use some code like the following:

Code: Alles auswählen

<we:ifField type="date" name="Enddatum" match="$today" operator="less">
where $today = date("Y-m-d") or even date("Y-m-d - H:m) like the date field "Enddatum" I use.

But, it doesn't seem to work correctly (or at all).

jftr: I use wE 6.4.1.

Re: Compare dates

Verfasst: Mi 8. Apr 2015, 11:20
von mokraemer
try

Code: Alles auswählen

<?php $today=time();?>
<we:ifField name="Enddatum" match="$today" operator="less">

Re: Compare dates

Verfasst: Mi 8. Apr 2015, 16:56
von ounos
mokraemer hat geschrieben:try

Code: Alles auswählen

<?php $today=time();?>
<we:ifField name="Enddatum" match="$today" operator="less">
Thank you, it worked! I had tried time() too using type="date" though.
Maybe, a clarification is needed in the documentation:
http://webedition.org/de/webedition-cms ... -type-date

Re: Compare dates

Verfasst: Di 14. Apr 2015, 12:18
von ounos
Hm, it seems that attribute "operator" does not work for "equal", only for "greater" or "less".

Is this a known bug ? Any workaround ?

Re: Compare dates

Verfasst: Di 14. Apr 2015, 13:40
von e_herrmann
hi,
did you try with type=date?

Re: Compare dates

Verfasst: Di 14. Apr 2015, 14:55
von ounos
e_herrmann hat geschrieben:hi,
did you try with type=date?
Yeap, ofc. That was my first attempt.
When I use that, it doesn't return any result.

Re: Compare dates

Verfasst: Di 14. Apr 2015, 16:21
von mokraemer
Currently dates are represented as UNIX-Timestamps, so they're not very likely equal.
If you want equality, you have to use type="date" and compare this to a formated date, as it is returned by we:field type="date"

Maybe we should make this here more userfriendly.

Re: Compare dates

Verfasst: Mi 15. Apr 2015, 10:14
von ounos
mokraemer hat geschrieben:Currently dates are represented as UNIX-Timestamps, so they're not very likely equal.
If you want equality, you have to use type="date" and compare this to a formated date, as it is returned by we:field type="date"

Maybe we should make this here more userfriendly.
<we:field type="date"/> returns a date-time. So, this won't be equal too.
Even if I try to format date, pass it to a global variable and compare them afterwards, doesn't work.