4 Replies - 786 Views - Last Post: 26 March 2013 - 12:11 PM Rate Topic: -----

#1 poldz123  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 52
  • Joined: 26-October 12

How to deduct the timestamp of PHP?

Posted 25 March 2013 - 04:56 PM

I am stuck with deducting the timestamp so I can delete message that is expired

It doesnt substract when I try to use this code

date_default_timezone_set('EST');
	$date = new DateTime();
	$newtime = $date->getTimestamp() - 1000000;



The timestamp was not subtracted to the value that I use?

Is there another way to do it??
Is This A Good Question/Topic? 0
  • +

Replies To: How to deduct the timestamp of PHP?

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: How to deduct the timestamp of PHP?

Posted 25 March 2013 - 05:03 PM

Hey.

You may want to look at the DateTime::modify method.

Also, keep in mind that timestamps in PHP are in seconds, not milliseconds like in Javascript. So 1000000 is read as 11.57 days.
Was This Post Helpful? 0
  • +
  • -

#3 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3077
  • View blog
  • Posts: 10,796
  • Joined: 08-August 08

Re: How to deduct the timestamp of PHP?

Posted 25 March 2013 - 08:12 PM

You might also look into using strtotime() which allows you to add/subtract weeks, days, hours, minutes and seconds using strings.
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: How to deduct the timestamp of PHP?

Posted 26 March 2013 - 01:13 AM

DateTime::modify does that too, by the way. It uses the same Date and Time formats strtotime does. It's basically just the OOP version of it.
Was This Post Helpful? 1
  • +
  • -

#5 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3077
  • View blog
  • Posts: 10,796
  • Joined: 08-August 08

Re: How to deduct the timestamp of PHP?

Posted 26 March 2013 - 12:11 PM

Didn't mean to imply that it didn't. ;)
Just offering another option. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1