Solved

php unixtime + 2 days

Posted on 2011-02-27
3
269 Views
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
0
Comment
Question by:NiconPhantom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 125 total points
ID: 34993440
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
 

Author Comment

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

Author Closing Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 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