Solved How to PDO expire date

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

guitarzRus

Thread Starter
Joined
Jul 28, 2020
Messages
50
Hi, I'm trying to confirm an expiraton date from a database table. I'm
finally trying PDO. I get:
Parse error: syntax error, unexpected 'y' (T_STRING) on line 10
--------------------------------------------------
The code:
PHP:
<?php
error_reporting(E_ALL); /* show all errors - server configured at 6135,
increases to 6143 (PHP version 5.2.11) -- comment this line out when LIVE
ini_set('display_errors','On'); // turn on error display -- comment this line out when LIVE */

   // set expiration date in YYYY-MM-DD format
$contract_expiration = '2021-08-25;

   // computes days remaining -- (60s*60m*24h) represents 1 day
$days_remaining = round( (( strtotime($contract_expiration) - strtotime(date('y-m-d')) ) / (60*60*24)) ); // line 10
if ($days_remaining < 31)
{
   // formats expiration date as M/D/YY
$contract_expiration_formatted = date('n/j/y',strtotime($contract_expiration));
   // alert message for contracts expiring today
if ($days_remaining == 7) $GLOBALS['contract_status'] = 'expires in a week!';
   // alert message for contracts expiring tomorrow
elseif ($days_remaining == 1) $GLOBALS['contract_status'] = 'expires tomorrow!';
   // alert message for contracts expiring in 2-30 days
else $GLOBALS['contract_status'] = 'expires in '.$days_remaining.' days - on '.$contract_expiration_
formatted;
//}
   // contract period is beyond 30 days
else $GLOBALS['contract_status'] = 'is current';
   // if today's date is greater than your expiration date
if (date('Y-m-d') > $contract_expiration)

{
header("location:pass-chek-php");
   // echo "We're sorry but your contract has expired...";
   // a status alert message or u can populate with web document
exit;
   // kills script & prevents parser from rendering your web app below
//}

else {  } ?>
 
Last edited by a moderator:

Couriant

James
Moderator
Joined
Mar 26, 2002
Messages
41,508
This will be your third warning about posting code without the correct tags. Make sure you are using the code function when posting. Failure to do so may result in a temporary ban.
 

colinsp

Colin
Joined
Sep 5, 2007
Messages
2,365
The warning is telling you what is wrong:

'y-m-d'

is invalid in this context

Take a look in the php manual for the correct use of strtotime.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top