php unixtime + 2 days

Posted on 2011-02-27
Medium Priority
Last Modified: 2012-05-11
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
Question by:NiconPhantom
  • 2
LVL 27

Accepted Solution

Lukasz Chmielewski earned 500 total points
ID: 34993440
Try this:

$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


Author Comment

ID: 34993441
I found it unix time + 172800 :-)

Author Closing Comment

ID: 34993448
Thank you very much, It was really easy, I just did $date+172800

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question