Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6042917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:50:34+00:00 2026-05-23T06:50:34+00:00

I am trying to insert a future date into a MySQL table from PHP.

  • 0

I am trying to insert a future date into a MySQL table from PHP. I have been able to insert the current date using strtotime but when I add time to this call it does not seem to insert it. Here is the code:

<?php
$currentDate = strtotime('now');
$expirationDate = strtotime('+ 90 days');

include_once "mysql-connect.php";       

$cur = "UPDATE table SET current_date = FROM_UNIXTIME($currentDate) WHERE ...";

if (!mysql_query($cur,$con))
{
die('Heres Your Error: ' . mysql_error());
}
echo "the date is set";

$exp = "UPDATE table SET expiration_date = FROM_UNIXTIME($expirationDate) 
WHERE ...";


if (!mysql_query($exp,$con))
{
die('Heres Your Error: ' . mysql_error());
}
echo " expiration date is set";

mysql_close($con)
?>

Like I said, when I run this it will insert the current date into the current_date row as requested. For some reason it will not insert expiration_date which is 90 days in front of the current date. I have verified that the expiration date is being picked up as 90 days in the future. Why is this not working?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:50:35+00:00Added an answer on May 23, 2026 at 6:50 am

    You can do it in MySQL directly:

    $days = 90;
    
    $sql = "UPDATE ... SET expiration_date = DATE_ADD(current_date, INTERVAL $days DAY);"
    

    which’ll save you the excess round-tripping from datetime->unix timestamp->datetime.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to INSERT INTO a table using the input from another table.
I'm trying to insert a file path into an empty MySQL table with PHP
Trying to insert values with Unicode Chars into a MySQL-database using Delphi 2010 and
I have code from my ad network that I am trying insert into an
When trying to insert data programatically using PHP, via the function date('c') It returns
Im trying to insert the userid into my table in a php file upload
I'm trying to insert a column into an existing DataSet using C#. As an
I've been trying insert a MapView into an ActionBar Tab , but I wasn't
I'm trying to insert some data into a table with shell_exec (on localhost). Here's
I was trying to insert some data into a table and I got the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.