To add 2 weeks to the current date using PHP, you can use the DateTime
class and the add()
method with the DateInterval
class.
Here's an example code snippet:
main.php184 chars4 lines
The add()
method takes a DateInterval
object as its parameter. In the example above, we create a new DateInterval
object representing a duration of 2 weeks using the P2W
format string. Finally, we use the format()
method to output the date 2 weeks from now in the desired format.
gistlibby LogSnag