Welcome Guest, Not a member yet? Register   Sign In
Date Manipulation Class
#1

[eluser]Vicente Russo[/eluser]
Just made a small library that helped me a lot. Maybe it can be useful for someone. This library can add or subtract days, months or years and return the result in mysql-ready format or timestamp.

Check it out!
#2

[eluser]sophistry[/eluser]
thanks for sharing... it's great to see such a nicely formatted and documented contribution.

but, (not to pop your bubble too hard) you need to look at this thread:

http://ellislab.com/forums/viewthread/120895/

basically, get to know the strtotime() function and you won't need this lib. it's much easier to let the PHP guys maintain code than to do it yourself!

cheers.
#3

[eluser]xwero[/eluser]
in php5.3 you can add or substract dates using the date_add and date_sub methods in procedural or OO style.
Code:
$date = new DateTime(); // same as time function
echo $date->add(new DateInterval("P5D"))->format('Y-m-d');
with the DateTime object the strtotime date modifying functionality is for the modify method
Code:
$date = new DateTime(); // same as time function
echo $date->add('+5 day')->format('Y-m-d');




Theme © iAndrew 2016 - Forum software by © MyBB