PHP - date after function

June 2017




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


Published by deri58. Latest update on June 29, 2010 at 11:25 AM by deri58.
This document, titled "PHP - date after function," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).