Velocity Script Incorrect Timezone conversion for America/Phoenix
I am having an issue trying to calculate the correct time for Arizona (America/Phoenix) in velocity script.
My script looks like this:
#* Get Lead Time Zone and convert Timezone calculator to lead's timezone*#
#set ($setTimeZone = $TriggerObject.leadTimeZone)
#if (!$setTimeZone || !($setTimeZone == "ET" || $setTimeZone == "CT" || $setTimeZone == "MT" || $setTimeZone == "PT" || $setTimeZone == "AZ"))
#set($setTimeZone = "ET")
#end
#if ( $setTimeZone == "ET")
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/New_York") )
#elseif ( $setTimeZone == "CT")
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Chicago") )
#elseif ( $setTimeZone == "MT")
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Denver") )
#elseif ( $setTimeZone == "PT")
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Los_Angeles") )
#elseif ( $setTimeZone == "AZ")
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Phoenix") )
#else
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/New_York") )
#end
#* Convert the time to Central and then back to lead time zone *#
#set( $inTimeZone = $date.getTimeZone().getTimeZone("America/Chicago"))
#set( $outTimeZone = $defaultTimeZone)
#set( $locale = $date.getLocale() )
#if($TriggerObject.visitDateStart)
#set( $myTimeStart = $convert.parseDate($TriggerObject.visitDateStart,'MM-dd-yy HH:mm',$locale,$inTimeZone) )
$date.format('hh:mm a',$myTimeStart,$locale,$outTimeZone)##
#end
Link to the zulu time and its conversions
Database input time: 2024-01-09T13:30:00Z
Marketo converts to: 2024-01-09 08:30:00
In the output, if the lead timezone is set as "AZ" the result I'm getting in the email is an hour behind.
5:30AM instead of 6:30AM.
I get the time correctly displaying for the other timezones (ET,PT,MT,CT).
I also tried outputting the timezone being used for America/Phoenix and I receive MST which is correct.
I am stumped, is there anything I can adjust for AZ to output the correct time?
Thank you!