Jump to content

Recommended Posts

OK. Quick dilemma here.

 

I have two dates. One is when a vehicle is "added" and one when it should be "deleted".

 

So it would look like this:

 

Added date: 2008-10-29

Deleted date: 2008-11-03

 

So I'm trying to do a psuedo "deleted - added = days left" but it doesn't work like that obviously.

 

Should I strip the "-" and try subtraction? But that won't always be accurate. What do you guys suggest?

Link to comment
https://forums.phpfreaks.com/topic/130613-subtracting-dates-to-get-days-left/
Share on other sites

Nevermind, figured it out:

 

	$added   = strtotime($row['_added']);
	$launch  = strtotime($row['_launch']);

                // show the date it goes off in a readable format
	$dateoff = date('M d, Y', strtotime($row['_launch']));

	$left    = ($launch - $added);

                // rounds it to days instead of seconds
	$left    = round($left / 86400);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.