PHP - Checking My Own Certificate Expiry Date
We are working on a new student application system. Due to privacy laws,
everything will be done behind https. However, this is one of many systems looked after by the system administrators. I would like to safeguard against the situation several years down the road when the certificate expires. There are several administration pages that will be checked frequently by the graduate admin assistant. While this person has no technical background, a warning several months before the certificate expires would allow her to remind the technical staff to renew the certificate. I know I can use curl to connect to my own server, but that seems like a long way to do it (and an extra https connection). Is there any way to get the certificate information for the current https connection from the server or from the php runtime? Similar TutorialsI'm trying to get an expiry date to work on my project.... but at the moment... it doesnt seem to be working. Heres the code for the main news submission form: Code: [Select] <form action='newsubmit.php' method='POST'> Title: <input type='text' name='title' /><br /> Story: <input type='text' name='story' /><br /> Upload Image: <a href="#" onclick="window.open('fileuploadprocess.php','mywindow','width=450,height=300,toolbar=no,location=no,directories=no,s tatus=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes')"> Click here</a> <?php require_once('../../../2740/recaptcha/recaptchalib.php'); $publickey = "6Ldbd8ASAAAAAL96lIWHSDRmoaVJhgQJuKQwXNbd"; echo recaptcha_get_html($publickey); ?> <input type='submit' name='submit' value='Submit' /> <input name='reset' type='reset' value='Reset' /> </form> Heres the code for the submission page: Code: [Select] <?php include_once("functions.php"); session_start(); $submit = clean_string($_POST['submit']); $title = clean_string($_POST['title']); $story = clean_string($_POST['story']); $datetoday = date('Y-m-d', $expires); $daystoexpire = '7'; $expires = time() + (86400 * $daystoexpire); $userid = $_SESSION['userID']; $newsimage = $_SESSION['imagelocation']; $message = ''; require_once('../../../2740/recaptcha/recaptchalib.php'); $privatekey = "6Ldbd8ASAAAAAFz8VT29H5w4WLNjsbI-mFY2QkaC"; $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); $message = ""; if ($submit == 'Submit') { if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $errMessage = $resp->error; $message = "<strong>The reCAPTCHA wasn't entered correctly. Please try again.</strong><br />" . "(reCAPTCHA said: $errMessage)<br />"; } else { // Process valid submission data here if ($title && $story) { //process details here if (strlen($title) > 80) { $message = "The title you have provided is too long. Please <a href='news_entry.php'>try again</a>"; } else { if (strlen($story) > 300) { $message = "The news story you have provided is too long. Please <a href='news_entry.php'>try again</a>"; } else { require_once("db_connect.php"); if ($db_server) { mysql_select_db("a200458721"); //Insert news story into news table $query = "INSERT INTO news (usersID, title, story, image, datetoday, expires) VALUES ('$userid', '$title', '$story', '$image', '$datetoday', '$expires')"; mysql_query($query) or die("User insert failed. " . mysql_error() . "<br />" . $query); $message = "News Story Successfully Submitted! Return to <a href='index.php'>homepage</a>"; } } } } else { $message = "Failed to connect to database"; } if ($expires < time()) { // Expired! } require_once("db_close.php"); } } else { $message = "please fill in all the required fields"; } echo $message; mysql_close($db_server); ?> At the moment, this is the error its throwing up: I'm not sure why its saying about the 1970 date either... User insert failed. Incorrect datetime value: '1303391514' for column 'expires' at row 1 INSERT INTO news (usersID, title, story, image, datetoday, expires) VALUES ('13', 'NEWS TITLE GOES HERE', 'NEWS STORY', '', '1970-01-01', '1303391514') Any ideas on why its throwing me up the error? I have a an array of dates, an array of normal weekly rates, and an array of seasonal rates. Items in the seasons array consist of: start, end, ongoing, and weekly rates. If the ongoing value is "Y" the season should apply to every year. If the value is "N" then the season should only last for the specified range. The below code is doing what i want except I just don't know how to incorporate the ongoing-ness of the seasonal rates. The last date in the dates array should affected by the second seasonal rates. Can't think of how to go about figuring this out. Code: [Select] <?php $dates[] = "1/26/2010"; $dates[] = "4/13/2011"; $dates[] = "4/19/2034"; $normal_rates = array( 'monday' => 0.99, 'tuesday' => 0.99, 'wednesday' => 0.99, 'thursday' => 0.99, 'friday' => 0.99, 'saturday' => 1.50, 'sunday' => 1.50, ); $seasons[] = array( 'start' => "3/15/2011", 'end' => "4/25/2011", 'ongoing' => "Y", 'monday' => 4.99, 'tuesday' => 4.99, 'wednesday' => 4.99, 'thursday' => 4.99, 'friday' => 4.99, 'saturday' => 10.99, 'sunday' => 10.99, ); $seasons[] = array( 'start' => "3/15/2011", 'end' => "4/25/2011", 'ongoing' => "N", 'monday' => 1.99, 'tuesday' => 1.99, 'wednesday' => 1.99, 'thursday' => 1.99, 'friday' => 1.99, 'saturday' => 19.99, 'sunday' => 19.99, ); foreach($dates as $date) { $x_timestamp = strtotime($date); $day_of_the_week = strtolower(date("l", strtotime($date))); $date_rates[$date] = $normal_rates[$day_of_the_week]; foreach($seasons as $key => $value) { $s_timestamp = strtotime($seasons[$key]['start']); $e_timestamp = strtotime($seasons[$key]['end']); if($x_timestamp >= $s_timestamp && $x_timestamp <= $e_timestamp) //should have an or(||) in it for ongoing { $date_rates[$date] = $seasons[$key][$day_of_the_week]; } } } Hello guys, I am new to PHP. I need some help. I am trying to build a web app, in which I have login functionality. I want to keep the logged in user session active for around 3-4 months. But in my case as soon as I close the browser, session data is lost and I need to login again. Can anyone help me with this. I've simply set some sessions.... $_SESSION['LoggedIn'] = 1; $_SESSION['UserID'] = $row["UserID"]; They don't seem to last very long, usually when I close my browser and go back on later, they'll expire. I want them to last permanently unless the user logs out. How do I do this? Thanks in advance. Hi, I have a specific php form in my website: example: www.website.com/form/ I want it to open in https://www.website.com/form/ it is working fine The problem is how can I force it to always open the form folder (index.php) in https Because if somebody removes the S in https:// the site will open normally. Thank you, I saw the posting for creating a script for a certificate but am struggling to get it to work, i have tried everything I can think of but getting errors.
As you can see from this test link there is php errors that cannot be resolved.
http://gmdesign.org.uk/xxx
I have also added the javascript to a button to print the certificate it but its not working either.
I would be grateful for any help you can give.
you can download/see my full scripts by viewing the attached files Hello everyone! I'm new to PHP (and to this forum, too). My final goal is to make a script that recognises which websites have an Extended Validation certificate type and which ones do not. Except I don't know how to do it. For starters, I should download the X.509 certificate and analyse it (I use both the OpenSSL and cURL PHP extensions), but how? DAYS of googling have brought me absolutely nothing. Any tips are appreciated. I can provide more detail if need be. I'd provide source code if I had any but I really don't know where to start... Thanks! Hello guys another difficult form case (for me) I have this super long form that pulls different files depending on what you select. The form works perfectly fine right now. the problem is that now the client need to run the form with a SSL certificate due to gov regulations. we are hosting all the files in the same folder for the secure and unsecure site and the certificate works fine. however when I run the form with the https:// address google chrome tells me that parts of the form are unsecured. I was reading something about the images have to be on a relative path using img scr="../images/path/file.ext" instead of just img scr="images/path/file.ext". I made that change and it didnt solve the problem. I changed all the links to " ../ " and didn't solve the problem. I have added rules to the .htaccess file RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^contact https://www.example.net/new-service.php [R=301,L] RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} somefolder RewriteRule ^(.*)$ https://www.example.net/inc/$1 [R,L] And even changed all the links in the form to absolute paths and nothing works. does anyone know how to force the form to work on SSL or troubleshoot SSL certificate errors to point me in the right direction thanks guys i appreciate your help and advice Let's say that I have domain called www.mydomain.com with SSL certificate. Through .htaccess I have set up the domain to force SSL at all times, so users will see https://www.mydomain.com/... I had this site and SSL for while and there are serveral external links linking to my site, but they are all (or most) in "SSL format" https://www.mydomain.com/... If I should cancel my SSL certificate (and remove force SSL in .htaccess) that will happen when those "SSL formatted" links get clicked on? I assume users will get "not trusted connection" message? Any way arround that? As far as I undersestand the "SSL" handshake takes place before .htaccess gets loaded, so I will not be able to force SSL off on the links.
Thoughts?
Edited by pioneerx01, 26 December 2014 - 03:01 AM. Should I always use HTTPS when users are inputting credit card numbers & billing info? Do you know any sites that don't use HTTPS? I just want to know if it's a total no-no for web applications. Discuss. I recently installed a SSL certificate for one of my domains, on a hosting account that includes several other domains. To redirect visitors to the SSL version of the website (because the SSL certificate only works for the www. version of the site) I use the following code in my .htaccess file:
#First rewrite any request to the wrong domain to use the correct one (here www.) I have this form that is far to long. I need to set it up in 3 pages. One page about the person getting the Gift Certificate, one for the person purchasing the certificate and another for credit card information. I have read about hidden variable but am a noobie. Any thoughts would be greatly appreciated. I've been looking for a function or a couple of functions which will allow me to get the Certificate Expiration date for a given website. I've tried openSSL, but their functions only seem to work on the current server, which is useless to me because my server doesn't allow SSL or certificates. I just want the certificate of an external website, e.g. www.gna.org has a certificate (signed by themselves, but a certificate nonetheless). I've also tried cURL, since that allows you to access a remote server, but that will just check their certificate - it doesn't offer any functionality for e.g. checking when it will expire. This seems like a simple enough question, but I haven't found anything about it anywhere, so I'm asking here. Thanks a bunch in advance, -IsmAvatar Hi folks, a few days back, we enabled SSL on our office server and the intranet migrated to https. Everything is ok on the intranet. On the public internet, we noticed today that the page on our website, which connects to our office server to fetch and display data was throwing an error, which I presumed was a Security Certificate issue... An area that's like the Dark Side of the Moon for me.. the webpage - https://liveconnections.in/hotjobs.php This is the error from the logs PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed PHP Warning: file_get_contents(): Failed to enable crypto PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Anycase, the internet was willing to help and so I updated the code to a curl function. The Data is not displaying still... Here's the code... where am i going wrong ? <?php //error_reporting(E_ERROR | E_PARSE | E_ALL); $page="jobs-listing"; ?> <header class="section background-livec text-center"> <h3 class="text-white margin-bottom-0 text-size-40 text-thin text-line-height-1">Current & Hot Jobs</h3> </header> <?php $industry = $_GET['industry']; $location = $_GET['location']; $expMin = $_GET['expMin']; $expMax = $_GET['expMax']; $sortBy = $_GET['sortBy']; $cpg = $_GET['page']; if(empty($cpg) || $cpg==1) $npl = 1; else { //$npl = (($cpg+1)*10) - 9; $npl = $_GET['startingRowNo']; } $industry = str_replace(' ', '%20', $industry); $location = str_replace(' ', '%20', $location); $url = "https://xx.xxx.xxx.xxx/WebService/rest/"; function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser. curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); curl_close($ch); return $data; } if(!empty($sortBy)) { $json = file_get_contents_curl($url.'getHeadersBySearch?industry='.$industry.'&location='.$location.'&expMin='.$expMin.'&expMax='.$expMax.'&sortBy='.$sortBy.'&startingRowNo='.$npl.'&noOfRows=1000000'); $data = json_decode($json); } else if(!empty($industry) || !empty($location) || !empty($expMin) || !empty($expMax)) { $json = file_get_contents_curl($url.'getHeadersBySearch?industry='.$industry.'&location='.$location.'&expMin='.$expMin.'&expMax='.$expMax.'&sortBy=&startingRowNo='.$npl.'&noOfRows=1000000'); $data = json_decode($json); } else { //$json = file_get_contents_curl($url.'getOnlineWebPosting'); $json = file_get_contents_curl($url.'getHeadersBySearch?industry='.$industry.'&location='.$location.'&expMin='.$expMin.'&expMax='.$expMax.'&sortBy=&startingRowNo='.$npl.'&noOfRows=1000000'); $data = json_decode($json); //if (!$data) echo "Data Not Found" ; } if($sortBy=='DESC' || $sortBy=='') { $aclass = 'down_arrow'; } else { $aclass = 'up_arrow'; } $json2 = file_get_contents_curl($url.'getSearchData'); $data2 = json_decode($json2); $industry = str_replace('%20', ' ', $industry); $location = str_replace('%20', ' ', $location); if($industry=='F amp A - BPO') { $industry = 'F & A - BPO'; } if($industry=='OIL amp GAS') { $industry = 'OIL & GAS'; } ?> <div class="section background-white"> <div class="background-white"> <p class="text-padding-bot text-letter-spacing1">A cross-section of Jobs currently available. We recommend you to contact our Executives for further info. <br /> More details available when the Job is '<strong>View'</strong>ed. </p> </div> <?php //$data=''; //if($data!=''){ ?> <?php //if ($checkyear>2017) { ?> <div class="subJobs"> <ul> <li> Industry <br /> <select name="industry" id="industry" class="sel"> <option value="">Select Industry Name</option> <?php for($i=0; $i<count($data2[0]); $i++) { ?> <?php if(isset($industry) && $industry==$data2[0][$i]) { ?> <option selected value="<?php echo $data2[0][$i];?>"><?php echo $data2[0][$i];?></option> <?php } else { ?> <option value="<?php echo $data2[0][$i];?>"><?php echo $data2[0][$i];?></option> <?php } } ?> </select> </li> <li>Location<br /> <select name="city" id="city" class="sel"> <option value="">Select City Name</option ><?php $m=0; for($j=0; $j<count($data2[1]); $j++) { ?> <?php $locat = explode(",",$location); ?> <?php if($locat[$m]!="" && $locat[$m]==$data2[1][$j]) { ?> <option selected value="<?php echo $data2[1][$j];?>"><?php echo $data2[1][$j];?></option> <?php ++$m; } else { ?> <option value="<?php echo $data2[1][$j];?>"><?php echo $data2[1][$j];?></option> <?php } } ?> </select> </li> <li>Experience <br /> <select name="minyear" class="sel2" id="minyear"> <option value="">Min</option> <?php for($ii=0; $ii<46; $ii++) { ?> <?php if($expMin!="" && $expMin==$ii) { ?> <option selected value="<?php echo $ii; ?>"><?php echo $ii; ?></option> <?php } else { ?> <option value="<?php echo $ii; ?>"><?php echo $ii; ?></option> <?php } } ?> </select> <select name="maxyear" class="sel2" id="maxyear" onchange="return select_max();"> <option value="">Max</option> <?php for($ii=0; $ii<51; $ii++) { ?> <?php if($expMax!="" && $expMax==$ii) { ?> <option selected value="<?php echo $ii; ?>"><?php echo $ii; ?></option> <?php } else { ?> <option value="<?php echo $ii; ?>"><?php echo $ii; ?></option> <?php } } ?> </select> <!-- select name="" class="sel2" id="sort"> <option value="">Select</option> <option value="ASC">ASC</option> <option value="DESC">DESC</option> </select --> </li> <li class="ser"><button type="button" onclick="search_by_category()" class="btn btn-default" style="margin-top:25px;"><i class="fa fa-search"></i> Search</button></li> </ul> </div> <!-- Selected Jobs Headline Info --> <div class="line"> <p class="text-dark text-center text-size-16"> <?php if($industry) echo 'Showing ' . '<b>' . $industry .'</b>' . ' Jobs' ; ?> <?php if($location) echo ' at ' . '<b>' . $location .'</b>' ; ?> <?php if($expMin) echo ' with Min ' . '<b>' . $expMin .'</b>' ; ?> <?php if($expMax) echo ' to Max '. '<b>' . $expMax.'</b>' ; ?> <?php if($expMin | $expMax) echo ' Years Experience' ;?> </p> </div> <!-- Jobs Table --> <table id="example" class="display" cellspacing="0" width="100%"> <thead> <tr> <th class="jobs_noshow text-center" width="5%">S.No</th> <th class="text-center" width="15%">Posted On</th> <th class="text-center" width="30%">Job Title</th> <th class="jobs_noshow text-center" width="15%">Level</th> <th class="jobs_noshow text-center" width="15%">Location</th> <th class="jobs_noshow text-center" width="15%">Job Code</th> <th class="text-center" width="5%">Action</th> </tr> </thead> <tbody> <?php $ri=1; foreach($data as $kk=>$d) { ?> <?php $date_posted = $d->postedDate; // get the Posted Date $date_posted_year=date("Y",strtotime($date_posted)); // Get the Year from the date and store in a variable if ($date_posted_year>$jobs_restrict_year) { // Show only Jobs posted after this year ?> <tr> <td class="jobs_noshow text-center"><?php echo $ri; ?></td> <td class="text-center"><?php echo $d->postedDate; ?></td> <td><?php echo $d->title; ?></td> <td class="jobs_noshow ctext notreq"><?php echo $d->level; ?></td> <td class="jobs_noshow text-center notreq"><?php echo $d->location; ?></td> <td class="jobs_noshow text-center"><?php echo $d->requirementID; ?></td> <td class="text-center"><a class="button background-livec border-radius text-white" style="color:white" data-fancybox="ajax" href="?contentid=jobs-detail&requirementID=<?php echo $d->requirementID; ?>&requirementSeqNo=<?php echo $d->requirementSeqNo; ?>" data-type="ajax">View</a></td> </tr> <?php } ?> <?php $ri=$ri+1; } ?> </tbody> </table> <script type="text/javascript"> $(document).ready(function () { var table = $('#example').DataTable( { "pageLength": 25, "sPaginationType":"full_numbers", "oLanguage": { "sInfo": 'Showing _START_ to _END_ of _TOTAL_ Jobs.', "sInfoEmpty": '', "sEmptyTable": "No Jobs found currently", } }); $('#example').removeClass( 'display' ).addClass('table table-striped table-bordered'); }); </script> <style> .dataTables_filter { display: none; } </style> <!-- End of Table --> </div> <?php // } else { ?> <div style="margin: 20px 0 40px 0px;height:200px;text-align:center;"> <h1 style="font-size:16px;">Server is unavailable at the moment. Please try after some time.</h1> </div> <?php //}?> </div> <!--jobs end--> <script type="text/javascript"> function search_by_category() { industry = $('#industry option:selected').val(); //city1 = $('#city option:selected').val(); minyear = $('#minyear option:selected').val(); maxyear = $('#maxyear option:selected').val(); //sortBy = $('#sort option:selected').val(); var city = $('select#city').val(); var cur_pg = "<?php echo $cpg; ?>"; var tot = "<?php echo $total; ?>"; var tot_pgs = Math.ceil(tot/25); //if(cur_pg=="") cur_pg = 1; var last_pg = tot_pgs - cur_pg; if(last_pg==0) records = tot - ((tot_pgs -1) * 25); else records = 25; var strt_val = ((cur_pg-1) * 25) + 1; if(industry=='F & A - BPO') industry ='F amp A - BPO'; if(industry=='OIL & GAS') industry ='OIL amp GAS'; city1 = document.getElementById("city").value; if(city1=="" || city1=="null") { city=""; } if(industry!="" || city!="" || minyear!="" || maxyear!="") { location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=&startingRowNo=1"+"&noOfRows="+records+"&page="+cur_pg; } else { //alert("Please select any one of the fields"); location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=&startingRowNo=1"+"&noOfRows="+records+"&page="+cur_pg; } } function sort_by_location() { var order = '<?php echo $sortBy; ?>'; industry = $('#industry option:selected').val(); city = $('#city option:selected').val(); minyear = $('#minyear option:selected').val(); maxyear = $('#maxyear option:selected').val(); city1 = document.getElementById("city").value; if(industry=='F & A - BPO') industry ='F amp A - BPO'; if(industry=='OIL & GAS') industry ='OIL amp GAS'; if(city1=="") { city=""; } else { city = $('select#city').val(); } if(order=="" || order=="DESC") { location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=ASC"+"&startingRowNo=1&noOfRows=10"; } else { location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=DESC"+"&startingRowNo=1&noOfRows=10"; } } function select_max() { minyear = document.getElementById("minyear").value; maxyear = document.getElementById("maxyear").value; if(parseInt(maxyear)>=parseInt(minyear)) { return true; } else { if(maxyear!="") { alert("Maximum year must be equal or greater than minimum year"); $('#maxyear').val(""); return false; } } } </script> Also, if i change the $url in my code to https:// , no data is displayed... I raised a Support request to the Hosting provider, but they seem to have vanished into the ozone.... Any help would be highly appreciated. Cheers - Murali
Hey, I'm using a script which allows you to click on a calendar to select the date to submit to the database. The date is submitted like this: 2014-02-08 Is there a really simple way to prevent rows showing if the date is in the past? Something like this: if($currentdate < 2014-02-08 || $currentdate == 2014-02-08) { } Thanks very much, Jack Hello. I'm new to pHp and I would like to know how to get my $date_posted to read as March 12, 2012, instead of 2012-12-03. Here is the code: Code: [Select] <?php $sql = " SELECT id, title, date_posted, summary FROM blog_posts ORDER BY date_posted ASC LIMIT 10 "; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $title = $row['title']; $date_posted = $row['date_posted']; $summary = $row['summary']; echo "<h3>$title</h3>\n"; echo "<p>$date_posted</p>\n"; echo "<p>$summary</p>\n"; echo "<p><a href=\"post.php?id=$id\" title=\"Read More\">Read More...</a></p>\n"; } ?> I have tried the date() function but it always updates with the current time & date so I'm a little confused on how I get this to work. Alright, I have a Datetime field in my database which I'm trying to store information in. Here is my code to get my Datetime, however it's returning to me the wrong date. It's returning: 1969-12-31 19:00:00 $mysqldate = date( 'Y-m-d H:i:s', $phpdate ); $phpdate = strtotime( $mysqldate ); echo $mysqldate; Is there something wrong with it? I have tried a large number of "solutions" to this but everytime I use them I see 0000-00-00 in my date field instead of the date even though I echoed and can see that the date looks correct. Here's where I'm at: I have a drop down for the month (1-12) and date fields (1-31) as well as a text input field for the year. Using the POST array, I have combined them into the xxxx-xx-xx format that I am using in my field as a date field in mysql. <code> $date_value =$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']; echo $date_value; </code> This outputs 2012-5-7 in my test echo but 0000-00-00 in the database. I have tried unsuccessfully to use in a numberof suggested versions of: strtotime() mktime Any help would be extremely appreciated. I am aware that I need to validate this data and insure that it is a valid date. That I'm okay with. I would like some help on getting it into the database. (continuing from topic title) So if I set a date of July 7 2011 into my script, hard coded in, I would like the current date to be checked against the hard coded date, and return true if the current date is within a week leading up to the hard coded date. How could I go about doing this easily? I've been researching dates in php but I can't seem to work out the best way to achieve what I'm after. Cheers Denno Hi, I have a job listing website which displays the closing date of applications using: $expired_date (This displays a date such as 31st December 2019) I am trying to show a countdown/number of days left until the closing date. I have put this together, but I can't get it to show the number of days. <?php $expired_date = get_post_meta( $post->ID, '_job_expires', true ); $hide_expiration = get_post_meta( $post->ID, '_hide_expiration', true ); if(empty($hide_expiration )) { if(!empty($expired_date)) { ?> <span><?php echo date_i18n( get_option( 'date_format' ), strtotime( get_post_meta( $post->ID, '_job_expires', true ) ) ) ?></span> <?php $datetime1 = new DateTime($expired_date); $datetime2 = date('d'); $interval = $datetime1->diff($datetime2); echo $interval->d; ?> <?php } } ?> Can anyone help me with what I have wrong? Many thanks |