[SOLVED] Expiry date |
9/20/2011 11:57:27 AM |
PHPRunner General questions | |
W
wundebar author
Hi at all! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=17796&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' /> |
|
C
|
cgphp 9/20/2011 |
There is a great article about conditional formatting here: http://xlinesoft.com/blog/2011/01/03/tutorial_conditional_formatting/ date("d/m/Y",strtotime(now())); |
![]() |
Sergey Kornilov admin 9/20/2011 |
As a first step you need to make sure your field in the database is able to accept datetime values. |
W
|
wundebar author 9/22/2011 |
There is a great article about conditional formatting here: http://xlinesoft.com/blog/2011/01/03/tutorial_conditional_formatting/ Anyway, to format a date use the date function as follow: date("d/m/Y",strtotime(now()));
if ($value < 0) {
and it works great! I have two colors, red for old dates and blu for records that are not expired yet, but the second problem isn't again solved <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=60978&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' /> i have again the "datetime" ( for admin, i have write bad last time) field like is saved into mysql database. |
C
|
cgphp 9/22/2011 |
if ($value<now()) |
W
|
wundebar author 9/23/2011 |
if ($value<now())
|
C
|
CK. 9/23/2011 |
Hi Cristian! It works great! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=61005&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> thank you very much! Anyway.. i see that empty records are automatically filled with 01/01/1970 how can avoid this?
|
C
|
cgphp 9/23/2011 |
if($value == "0000-00-00 00:00:00")
|
W
|
wundebar author 9/23/2011 |
The above condition show only $value > now() and $value < now(). How about the condition for $value == now()? Base on your requirement, if ($value<now()) { $value = "<span style='color:red'>".date("d/m/Y",strtotime($value))."</span>"; } else { $value = "<span style='color:blue'>".date("d/m/Y",strtotime($value))."</span>"; } Than means whatever greater or equal to now() will turn red. I'm not sure this one working not $value = "<span style='color:".($value<now()? 'red': 'blue')."'>".date("d/m/Y",strtotime($value))."</span>"; Regards, CK
if($value == "0000-00-00 00:00:00")
|
C
|
cgphp 9/23/2011 |
Check in phpmyadmin the date values for empty record and let me know. |
W
|
wundebar author 9/23/2011 |
Check in phpmyadmin the date values for empty record and let me know.
|
C
|
cgphp 9/23/2011 |
Not the structure but the data. Check the date field value for records where date was left empty. |
W
|
wundebar author 9/23/2011 |
Not the structure but the data. Check the date field value for records where date was left empty.
|