Solved

php unixtime + 2 days

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now