Solved

php unixtime + 2 days

Posted on 2011-02-27
3
270 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

734 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