View Full Version : calculating dates in PHP
gurmeet
02-10-2010, 09:25 AM
how i can calculates dates n ages in PHP
my all dates are stores in database as unix timestamp..
is there any predefined functions which can b used to calculate dates ? i.e.
i did some activity on 12-01-10 and on 12-02-10 it l show me that 1 month gone for this activity etc?
thanks in advanced...
gurmeet
02-10-2010, 09:26 AM
? post soon plz
djr33
02-10-2010, 09:39 AM
http://www.php.net/manual/en/function.strtotime.php
http://www.php.net/manual/en/function.date.php
Input a formatted date(s) and convert to a timestamp using strtotime() or a similar function.
Then do math on the date(s) and use date() to format as needed.
There is no "default" way to do this, but depending on your needs, you can put together a combination of a few functions to accomplish any necessary math.
gurmeet
02-11-2010, 06:02 AM
wel thanks...
i already done like this.. but i was looking for some better methods...\
djr33
02-11-2010, 07:09 AM
The only better method would be to write a function for yourself that automates the process, using those functions as the base.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.