[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Change value of time

Posted on 2011-04-25
6
Medium Priority
?
281 Views
Last Modified: 2012-05-11
Hi all,

I have a php script that has this line of code:

$expire = time()+(30*24*3600);

From what I understand this sets the $expire to a date that 30 days from current time.

What do I need to do to change it so that it becomes 90 days from a date that is 30 days prior to current date?

For example
Today's date  = 26/04/2011
Expiry date = 26/03/2011 + 90 days = 26/06/2011

0
Comment
Question by:AnuarJamlus
  • 3
  • 2
6 Comments
 
LVL 1

Author Comment

by:AnuarJamlus
ID: 35463918
Didn't realise everyone is givign away 500 points...  Adding additional points to this question.
0
 
LVL 1

Author Comment

by:AnuarJamlus
ID: 35463922
Hmmm...  ok... still not 500 points. Guess this should do it...
0
 
LVL 2

Expert Comment

by:vogen
ID: 35463981
Hi AnuarJamlus.
here is a ref.
http://www.w3schools.com/php/php_date.asp

it shows how to play with date function in php
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Expert Comment

by:larsrohr
ID: 35464534
As the link provided by vogen points out, mktime is typically used for messing around with arbitrary dates.

But as for your code, it's using the time() function to calculate the number of seconds since the "unix epoch",
and adding 30 days * 24 hours/day * 3600 seconds/hour.
(see also http://php.net/time)

To adjust that as desired, note that "90 days from a date that is 30 days prior to current date" is just 60 days from now (if I understood you correctly),
so you could just change it to:
  $expire = time()+(60*24*3600);
0
 
LVL 1

Author Comment

by:AnuarJamlus
ID: 35464569
Yes I guess that is one way to look at it.

I guess what I am really looking for was a way to deduct from a time then add to that time. Is it possible to do a time() - (60*24*3600); to get a time that is 60 days in the past?
0
 
LVL 12

Accepted Solution

by:
larsrohr earned 2000 total points
ID: 35464587
Absolutely.  time(), being simply a count of seconds since the epoch, is just a big integer.  You can subtract (60*24*3600) from it just fine.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…
Suggested Courses
Course of the Month20 days, 3 hours left to enroll

872 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