Compare dates

Benutzeravatar
ounos
Member
Beiträge: 44
Registriert: Mi 6. Aug 2014, 11:09

Compare dates

Beitragvon ounos » Mi 8. Apr 2015, 10:02

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.

mokraemer
Senior Member
Beiträge: 2569
Registriert: So 8. Aug 2010, 01:23
Wohnort: Mainz

Re: Compare dates

Beitragvon mokraemer » Mi 8. Apr 2015, 11:20

try

Code: Alles auswählen

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

Benutzeravatar
ounos
Member
Beiträge: 44
Registriert: Mi 6. Aug 2014, 11:09

Re: Compare dates

Beitragvon ounos » Mi 8. Apr 2015, 16:56

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

Benutzeravatar
ounos
Member
Beiträge: 44
Registriert: Mi 6. Aug 2014, 11:09

Re: Compare dates

Beitragvon ounos » Di 14. Apr 2015, 12:18

Hm, it seems that attribute "operator" does not work for "equal", only for "greater" or "less".

Is this a known bug ? Any workaround ?

e_herrmann
Senior Member
Beiträge: 1273
Registriert: Do 22. Mai 2003, 23:25

Re: Compare dates

Beitragvon e_herrmann » Di 14. Apr 2015, 13:40

hi,
did you try with type=date?
Elko Herrmann
komplexx | internet.fotografie
web: http://www.komplexx.de

Benutzeravatar
ounos
Member
Beiträge: 44
Registriert: Mi 6. Aug 2014, 11:09

Re: Compare dates

Beitragvon ounos » Di 14. Apr 2015, 14:55

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.

mokraemer
Senior Member
Beiträge: 2569
Registriert: So 8. Aug 2010, 01:23
Wohnort: Mainz

Re: Compare dates

Beitragvon mokraemer » Di 14. Apr 2015, 16:21

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.
webEdition-Kern-Entwickler

Benutzeravatar
ounos
Member
Beiträge: 44
Registriert: Mi 6. Aug 2014, 11:09

Re: Compare dates

Beitragvon ounos » Mi 15. Apr 2015, 10:14

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.


Zurück zu „webEdition Basic Version“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast