Datetime retrieved from db is 7 hours off? I am having trouble displaying the correct date, well actually its only the time.

In the db the date is stored in this form: 2012-09-28 23:30:00

That is the value for a date of an event.

When I retrieve it using this script: 

$ttdate = $obj-&gt;field_date_test_value;
$nttdate = strtotime($ttdate);
$okdate = format_date($nttdate, $type = 'medium');
print $okdate;


...it works fine but the time is off by 7 hours.
So instead of showing Fri, 9/28/2012 - 4:30pm it shows Fri, 9/28/2012 - 11:30pm.

Note that on the event's page, drupal retrieves the correct time...

I did some research and I figured it has to do with the timezone? But I have the timezone set to Los Angeles so I am not quite sure what is going on. Maybe its my script?
Date/times are generally stored in the database as UTC, so if your timezone is UTC -7 hours then all your times will be out by 7 hours (between the database and your expected output).

When you load a date from the database you then have to apply the desired timezone before displaying it or doing calculations on it or whatever.

For some examples you can see what the date module does with:
date_formatter_process() and
date_tokens()

It creates a new DateObject and then runs date_timezone_set($date, timezone_open($timezone)); on that date to set the timezone.

If you just want to use the site timezone (or user selected timezone) you can use date_default_timezone().

There is also the drupal core function format_date(), which takes a timestamp, a date format, and a timezone and gives you the output date.
That would be the easiest option.

For example, you might do this:

$okdate = format_date($nttdate, 'medium', '', date_default_timezone());