$day = date("Y-m-d", strtotime('+1 month', time())) . " " . "$hour" . ":".  "$minute" . ":" . "00" . "$ampm";
	$day->setTimezone(new DateTimeZone('$ftz'));

I have a user enter a time and I want to generate a $day one month ahead of the day the script was called at the time entered

So for example if I entered 5:10pm PST

$day would become "09-14-2010 05:10:00 PM"

and then I want to convert that timezone to EST so everyones is similar and when I do the
day-> settimezone I get this error:

"Fatal error: Call to a member function setTimezone() on a non-object in"

Any ideas whats going wrong? (note $ftz = "America/New_York"; )

<?php

//Set date according to formats accepted by strtotime
//Set timezone to use
$day = new DateTime('yyyy-mm-dd', new DateTimeZone('America/New York'));

//Modify to one month in future
$day->modify('+1 month'); 

//Display updated date
echo $day->format('Y-m-d');

This isn't tested. but the date() function in php does not return an object and in your code, $day would actually be a string. This would cause the non-object error.

This updated code should do what you want, but I haven't tested it.

<?php

//Set date according to formats accepted by strtotime
//Set timezone to use
$day = new DateTime('yyyy-mm-dd', new DateTimeZone('America/New York'));

//Modify to one month in future
$day->modify('+1 month'); 

//Display updated date
echo $day->format('Y-m-d');

This isn't tested. but the date() function in php does not return an object and in your code, $day would actually be a string. This would cause the non-object error.

This updated code should do what you want, but I haven't tested it.

How about the inputs? $hour, $minute, $ampm? How can I incorporate those?

you can use phps built in strtotime()

tutorial

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.