473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Time conversion

I'm a novice in this subject....I've made a database that requires a
time conversion. For example, if local time is 1200, determine the
time in Korea. I use two fields: a date field, and a time field. I
need the converted time to show up in a report. I also need the
corresponding date to increment if necessary. Any ideas on how to do
this would be greatly appreciated.
Nov 12 '05 #1
1 11641
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The world is divided into different time zones (see the Map of time
zones, below). Each zone is designated X number of hours from
Greenwich Mean Time (or UTC: Universal Temp Coordination [Universal
Coordinated Time] - pardon my French). To get an accurate time of a
location in the world you'd have to convert your time to UTC (when
your time zone is negative, you'd have to ADD hours to UTC; when your
time zone is positive, you'd have to SUBTRACT hours from UTC.) then
add/subtract number of hours other location is from UTC.

Example (this doesn't include Day Light Savings Time [another can of
worms, since each country defines their own], see free time conversion
software, below):

Oakland time: 21 Nov 2003 1200.

Oakland is -8 UTC
Get UTC: 1200 + 8 = 2000 UTC

Korea is +9 UTC
Get Korea's time relative to previously calculated UTC:
2000 + 9 = 2900 = 1 day & 5 hrs or 22 Nov 2003 0500

===

Items from Google search on "time zone":

Map of time zones:
http://www.worldtimezone.com/

Free software to get time in different zones (untested):
http://www.timezonesforpcs.com/details.htm
Here is some VBA code I devised to get UTC.

== Begin Code ==

Private Const LOCALE_SYSTEM_DEFAULT& = &H800

'**********************************
'** Type Definitions:

Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Private Declare Sub GetSystemTime Lib "kernel32" _
(lpSystemTime As SYSTEMTIME)

Private Declare Sub GetLocalTime Lib "kernel32" _
(lpSystemTime As SYSTEMTIME)

Private Declare Function GetTimeFormat& Lib "kernel32" Alias _
"GetTimeFormatA" (ByVal Locale As Long, ByVal dwFlags As Long,
_
lpTime As SYSTEMTIME, ByVal lpFormat As Long, _
ByVal lpTimeStr As String, ByVal cchTime As Long)

Sub ShowTime()

Dim myTime As SYSTEMTIME
Dim strBuffer As String
Dim lng As Long

GetLocalTime myTime
strBuffer = String$(255, Chr$(0))
lng = GetTimeFormat&(LOCALE_SYSTEM_DEFAULT, 0, _
myTime, 0, strBuffer, 254)
Debug.Print "Local Time = "; strBuffer
With myTime
Debug.Print "Local Date = "; _
DateSerial(.wYear, .wMonth, .wDay)
End With

GetSystemTime myTime
strBuffer = String$(255, Chr$(0))
lng = GetTimeFormat&(LOCALE_SYSTEM_DEFAULT, 0, _
myTime, 0, strBuffer, 254)
Debug.Print "GMT Time = "; strBuffer
With myTime
Debug.Print "GMT Date = "; _
DateSerial(.wYear, .wMonth, .wDay)
End With

End Sub

== End Code ==

HTH,

MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP78Qk4echKqOuFEgEQJYbgCeLV+f5fbdUyBG+0iWf3cI3L d+XyYAoN+q
3CMpyI3yxEqOlGJtQu2rjes7
=yo22
-----END PGP SIGNATURE-----

heirou wrote:
I'm a novice in this subject....I've made a database that requires a
time conversion. For example, if local time is 1200, determine the
time in Korea. I use two fields: a date field, and a time field. I
need the converted time to show up in a report. I also need the
corresponding date to increment if necessary. Any ideas on how to do
this would be greatly appreciated.

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dan glenn | last post by:
Say, I want to set a cookie and have it expire an hour after it's set. It's looking like this is only possible for browsers which are in the same time zone as my server?? In other words, if I...
2
by: learning_C++ | last post by:
I programmed this code with a function "get_current_time" in the begining. When I compiled with the command g++ -Wall -g xxx.xpp -o xxx there are so many errors. please help me and thanks, ...
6
by: DCSudolcan | last post by:
I know that a program can create and properly initialize an array of pointers to functions at build time, but can something like the following be done at build time? void foo(void); unsigned...
5
by: Paulers | last post by:
Hello, I'm working on an app that requires the functionality to convert the time in Austrailia to the time in New York (EST). I am wondering, what is the bestway to approach this in vb.net? Is...
3
by: Jason S | last post by:
is there any way to use templates to bind integer/floating point constants to a template for compile-time use? e.g. template <double conversion> class meters { const factor = conversion;
3
by: moni | last post by:
Hi, I wanted to convert a time value in the form of time_t into a readable form in C# or vice versa, in order to be able to subtract two time values and give the result in msecs. eg. I...
3
by: Evan Klitzke | last post by:
Although it is not present in ANSI C, the GNU version of stftime supports the conversion character %z, which is a time offset from GMT. The four digit time offset is required in RFC 2822...
5
by: fimarn | last post by:
I am trying to get rid of compile time error that I am getting only in RHEL5 (not in RHEL4) apparently due to the changes in the stl_list.h file. The error that I am getting is coming from the...
5
by: Grey Alien | last post by:
I need to convert timestamps that are given as the number of seconds that have elapsed since midnight UTC of January 1, 1970, (not counting leap seconds). It seems all of the std C functions...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.