Storing the datetime in UTC value is the go. Here are the code to convert a given date time to UTC and a UTC date time to powerbuilder datetime values.
--Create global external function
FUNCTION long uuidCreate(ref s_uuid astr_uuid) LIBRARY "Rpcrt4.dll" ALIAS FOR "UuidCreate"
FUNCTION ulong GetTimeZoneInformation (ref TIME_ZONE_INFORMATION lpTimeZoneInformation) Library "kernel32"
FUNCTION boolean SystemTimeToTzSpecificLocalTime(TIME_ZONE_INFORMATION lpTimeZone, SYSTEMTIME lpUniversalTime, ref SYSTEMTIME lpLocalTime ) Library "kernel32"
FUNCTION boolean TzSpecificLocalTimeToSystemTime(TIME_ZONE_INFORMATION lpTimeZone, SYSTEMTIME lpLocalTime, ref SYSTEMTIME lpUniversalTime ) Library "kernel32"
_______________________________________________________________________________________________
-- function to convert passed date time to UTC
function f_convert_sysdatetime_to_UTC (as_systemdate datetime)
TIME_ZONE_INFORMATION tzi
SYSTEMTIME utc
SYSTEMTIME pst
ulong rc
boolean rc2
//Get's local time zone
rc = GetTimeZoneInformation(tzi)
//Convert PowerBuilder datetime to SYSTEMTIME for UTC
UTC.wYear = Year(Date(as_systemdate))
UTC.wMonth = Month(Date(as_systemdate))
UTC.wDay = Day(Date(as_systemdate))
UTC.wHour = Hour(Time(as_systemdate))
UTC.wMinute = Minute(Time(as_systemdate))
UTC.wSecond = Second(Time(as_systemdate))
UTC.wMilliseconds = 0
// Convert to UTC
rc2 = TzSpecificLocalTimeToSystemTime(tzi, UTC, pst)
//Convert SYSTEMTIME to PowerBuilder datetime
Return DateTime ( Date ( pst.wYear, pst.wMonth, pst.wDay ), Time ( pst.wHour, pst.wMinute, pst.wSecond ) )
______________________________________________________________________________________________________________________
--function to convert UTC datetime to systemdate time
function f_convert_utc_to_systemdatetime (as_utc datetime)
TIME_ZONE_INFORMATION tzi
SYSTEMTIME utc
SYSTEMTIME pst
ulong rc
boolean rc2
//Get's local time zone
rc = GetTimeZoneInformation(tzi)
//Convert PowerBuilder datetime to SYSTEMTIME for UTC
UTC.wYear = Year(Date(as_utc))
UTC.wMonth = Month(Date(as_utc))
UTC.wDay = Day(Date(as_utc))
UTC.wHour = Hour(Time(as_utc))
UTC.wMinute = Minute(Time(as_utc))
UTC.wSecond = Second(Time(as_utc))
UTC.wMilliseconds = 0
//Convert to local time zone
rc2 = SystemTimeToTzSpecificLocalTime(tzi, UTC, pst)
//Convert SYSTEMTIME to PowerBuilder datetime
Return DateTime ( Date ( pst.wYear, pst.wMonth, pst.wDay ), Time ( pst.wHour, pst.wMinute, pst.wSecond ) )
____________________________________________________________________________________________________________________
Hope this helps.