Toyota Supra 3.0i Turbo Targa in Panther Black Mica - 300D || 30D || 10-20 || 50mm 1.8 mk1 || 18-55 || 17-85 || 75-300 || Giottos || Manfrotto || Cullmann || Kenko || Hoya
Sybr_E-N:
Sla je die timestamp in MySql op als een MySql-timestamp of een Unix-timestamp. En als je het opslaat als een MySql-timestamp convert je deze dan wel goed naar een Unix-timestamp (die nodig is voor mktime & co).?
DATETIME dus. Niet timestamp.C.44:
(...) waarin ik een kolom heb (type DATETIME) (...)
Kijk eens naar de functies van MySQL om met data te rekenenHebben jullie enig id waar ik dit zou moeten zoeken ?
Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz
ik sla gewoon $currentdate op naar die kolom. $currentdate bevat dan:Sybr_E-N schreef op 30 maart 2003 @ 17:51:
Sla je die timestamp in MySql op als een MySql-timestamp of een Unix-timestamp. En als je het opslaat als een MySql-timestamp convert je deze dan wel goed naar een Unix-timestamp (die nodig is voor mktime & co).?
1
| $currentdate = date("Y-m-d G:i:s"); |
verder doe ik er nix mee
De $maxdate geeft ook netjes de uitkomst die ut zou moeten geven.
dus in feite komt er dat te staan (ik neem wat willekeurige data)
1
2
3
4
5
6
7
8
9
| if (2003-03-30 14:58:10 > 2003-03-30 05:58:10) { echo "joepie"; } else { echo "notsogood"; } |
Toyota Supra 3.0i Turbo Targa in Panther Black Mica - 300D || 30D || 10-20 || 50mm 1.8 mk1 || 18-55 || 17-85 || 75-300 || Giottos || Manfrotto || Cullmann || Kenko || Hoya
Nogmaals: los dit op met MySQL, niet met PHP.
Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz
Ey dat vat ikdrm schreef op 30 March 2003 @ 18:05:
Je vergeet dat als PHP een string gebruikt in een integer comparison, de integer genomen wordt aan het begin van de string totdat een non-integer karakter tegengekomen wordt. In dit geval is dat dus het streepje ('-') na 2003. Feitelijk wordt dus gekeken of 2003 groter is dan 2003. Nee, dus.
Nogmaals: los dit op met MySQL, niet met PHP.
[ Voor 9% gewijzigd door C.44 op 30-03-2003 18:09 ]
Toyota Supra 3.0i Turbo Targa in Panther Black Mica - 300D || 30D || 10-20 || 50mm 1.8 mk1 || 18-55 || 17-85 || 75-300 || Giottos || Manfrotto || Cullmann || Kenko || Hoya
Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz
hehe, is my middlenamedrm schreef op 30 March 2003 @ 18:13:
Kan ook, maar dan doe je overdreven moeilijk.
Thanks for thinking along
Toyota Supra 3.0i Turbo Targa in Panther Black Mica - 300D || 30D || 10-20 || 50mm 1.8 mk1 || 18-55 || 17-85 || 75-300 || Giottos || Manfrotto || Cullmann || Kenko || Hoya
drm, hoe wil je dit oplossen in sql. Wil je een if-statement opnemen in de select-clause of zit je te denken aan twee statements voor de twee gevallen?
1
2
3
4
5
6
| SELECT DATE_ADD( datumveld, INTERVAL 12 HOUR ) > NOW () AS is_less_than_twelve_hours_ago |
even een huge naam voor de duidelijkheid
Vervolgens evalueert '0' in PHP in een boolean situatie (if) false op, en kun je dus gewoon voor elk record
1
2
3
| if ( $record [ 'is_less_than_twelve_hours_ago' ] ) { // ... } |
Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz