Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

php unixtime + 2 days

Hi guys

I have variable $date which equals unix time format (for exaple 1298835792). What is the easyest way to add + 2 days to my unix date and then return new date in format: date ("Y-m-d")?

Another key point is to display $date2 in correct time format for example if in this month only 28 days, + 2days shoud be != 30
0
NiconPhantom
Asked:
NiconPhantom
  • 2
1 Solution
 
Lukasz ChmielewskiCommented:
Try this:
http://www.dbforums.com/php/1009880-how-add-days-specific-date-php.html

<?php 
$timestamp=time(); //current timestamp
echo "Current Time: $timestamp<br>";
$tm=$timestamp+172800; // Will add 2 days to the $timestamp
$da=date("F j, Y, g:i a", $timestamp);
echo "Current time string: $da <br>";
$da1=date("F j, Y, g:i a", $tm);
echo "Modified time: $da1 <br>";
?>

Open in new window

0
 
NiconPhantomAuthor Commented:
I found it unix time + 172800 :-)
0
 
NiconPhantomAuthor Commented:
Thank you very much, It was really easy, I just did $date+172800
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now