Jump to content

Create new date from max date


Terminaxx

Recommended Posts

Hey guys,

 

first I want to apologize for my English and hope you still understand what i am trying to do.

 

So i got a table with many timestamps in it - like this: 2017-11-04 00:00:00

 

I want to get the object with the highest timestamp (the farest day) and add exactly one day to it and add it to the table.

 

Like if we say the above timestamp was the highest, the next one should be like this: 2017-11-05 00:00:00

 

 

How can i do this and add it to the table without any error?

 

 

Thanks for any help

Link to comment
Share on other sites

The main problem is, how to get the timestamp out of the table, add 1 day and put it as a new column in.

 

Therefore I got problems with representing the timestamp in the right order.

 

 

I tried this:

                $highdate = mysqli_fetch_object(mysqli_query($con, "SELECT * FROM auctions ORDER BY yourdate DESC LIMIT 1"))->yourdate;
                
                $date = date_create('$highdate');
                date_add($date, date_interval_create_from_date_string('2 days'));

(tried it here with 2 days) but in the table i got it in this format: 0000-00-00 00:00:00

Link to comment
Share on other sites

Your code is so flawed in your example that you have WAY more problems that a little date math.

 

Why are you fetching an object?

 

You originally showed us a date value that looked just like what one gets from a query. Why make it part of an object? It was perfect as it was.

 

Make a date value out of it. Read the Manual and look at the examples for date()

 

Then look at the reference I gave you.

 

Then do some more reading on how to enclose a php variable in quotes properly.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.