How to set color have date field regarding visitor date

How to set color have date field regarding visitor date

  • Published by
    serge billon
  • Last modified
    19 January 2021
  • Voting
    Average rating
  • Favourites
  • Tags
  • Concerns
    Plugins Template
  • Since Version
    3.X
  • Up to date
    Yes
  • Profile concerned
    Webdesigner, Developer

if you want to change color regarding ending date

1 create a date field

2 in your item vue edit php and add this whre you want to display it

<?php  

$Now = date();
     
$Date30d = date('Y-m-d', strtotime($Now. ' + 30 days'));
$field_id= XXX, // your flexicontent field idea 
$fvals = isset($item->fieldvalues[$field_id]) ? $item->fieldvalues[$field_id] : array();

        if(strtotime($fvals[0]) > strtotime($Date30d)){      // $fvals[0] for first value in field

            $datecss="green";      
         }else{      
               $datecss="red";    
           }      
         echo "<span class=\"".$datecss."\">".fvals[0]."</span>";
?>




Now you value have class regarding date field , you can set color via css

© 2018 Flexicontent. All Rights Reserved.