PHP - date after function

December 2016




Issue


I'd like to stop displaying the variable generate the date after of my events

Example: We are the 28th June, and I would like to make a code

If June 28 is not yet past, display "on June 28 by appointment at xxx"

Solution


You must enter the timestamp of the 28June

Identify the timestamp of the 29 Juin and set your contiditons:

timestamp_actual = mktime(actual date); 
timestamp 29_juin = mktime(date du 29 juin); 

//  verify syntax for mktime() ! 

if(timestamp_actual < timestamp 29_juin) 
display




E.g:



$timestamp_actual = mktime(0, 0, 0, 6, 28, 10); 

  
$timestamp_xxx1 = mktime(0, 0, 0, 6, 27, 10);  
$timestamp_xxx2 = mktime(0, 0, 0, 6, 29, 10);  
  

if($timestamp_actual < $timestamp_xxx1)  
echo "apointment on the 27 at xxx1"; 


if($timestamp_actuel < $timestamp_michou)  
echo "apointment on the 29 at xxx1"; 


Thanks to azerty0 and cedfid for this tip.

Related :

This document entitled « PHP - date after function » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.