From: briana on 19 Oct 2006 06:48 This is probably something simple. I'm trying to get the current time in EPOC time, which is, I believe, also called time_t in C. I think the GETLOCALTIME API call will do what I want, but I'm not sure. Reason I want this is to feed it to a printer that requires a match to the epoch time before it will serve status pages back via HTTP. Any ideas? Brian A.
From: briana on 19 Oct 2006 11:50 Well, I found the answer. To get the current time in EPOCH format, or TIME_T, if you prefer, it's just: DIM E_Time as String E_Time = DATEADD("s","1/1/1970",NOW) This does is only as close as the nearest second, so you may have to pad with zeros to get the string to the proper length. Brian A
From: Bob Butler on 19 Oct 2006 12:10 "briana" <briana(a)att.net> wrote in message news:1161273048.073566.315860(a)m7g2000cwm.googlegroups.com > Well, I found the answer. To get the current time in EPOCH format, or > TIME_T, if you prefer, it's just: > > DIM E_Time as String > E_Time = DATEADD("s","1/1/1970",NOW) FWIW, it's generally better to avoid string to date conversions. With "1/1/1970" it doesn't matter much since it's going to get converted correctly but with "1/2/1970" the app will run differently on different PCs because that could be Jan 2 or Feb 1. Use the #mm/dd/yyyy# to specify date constants to avoid that potential pitfall: E_Time = DATEADD("s", #1/1/1970#, Now) -- Reply to the group so all can participate VB.Net: "Fool me once..."
From: Stefan Berglund on 19 Oct 2006 13:05 On Thu, 19 Oct 2006 09:10:25 -0700, "Bob Butler" <tiredofit(a)nospam.ever> wrote: in <eoi#Wk58GHA.3396(a)TK2MSFTNGP04.phx.gbl> >"briana" <briana(a)att.net> wrote in message >news:1161273048.073566.315860(a)m7g2000cwm.googlegroups.com >> Well, I found the answer. To get the current time in EPOCH format, or >> TIME_T, if you prefer, it's just: >> >> DIM E_Time as String >> E_Time = DATEADD("s","1/1/1970",NOW) > >FWIW, it's generally better to avoid string to date conversions. With >"1/1/1970" it doesn't matter much since it's going to get converted >correctly but with "1/2/1970" the app will run differently on different PCs >because that could be Jan 2 or Feb 1. Use the #mm/dd/yyyy# to specify date >constants to avoid that potential pitfall: >E_Time = DATEADD("s", #1/1/1970#, Now) How does that avoid the ambiguity? Doesn't it still rely on locale settings and so would be different on different machines? Personally I prefer the unambiguous format yyyymmdd. --- Stefan Berglund
From: Bob Butler on 19 Oct 2006 13:34 "Stefan Berglund" <sorry.no.koolaid(a)for.me> wrote in message news:d0cfj25rb8haapeklnumqub16uhuaimhuc(a)4ax.com > On Thu, 19 Oct 2006 09:10:25 -0700, "Bob Butler" > <tiredofit(a)nospam.ever> wrote: > in <eoi#Wk58GHA.3396(a)TK2MSFTNGP04.phx.gbl> > >> "briana" <briana(a)att.net> wrote in message >> news:1161273048.073566.315860(a)m7g2000cwm.googlegroups.com >>> Well, I found the answer. To get the current time in EPOCH format, >>> or TIME_T, if you prefer, it's just: >>> >>> DIM E_Time as String >>> E_Time = DATEADD("s","1/1/1970",NOW) >> >> FWIW, it's generally better to avoid string to date conversions. >> With "1/1/1970" it doesn't matter much since it's going to get >> converted correctly but with "1/2/1970" the app will run differently >> on different PCs because that could be Jan 2 or Feb 1. Use the >> #mm/dd/yyyy# to specify date constants to avoid that potential >> pitfall: E_Time = DATEADD("s", #1/1/1970#, Now) > > How does that avoid the ambiguity? Doesn't it still rely on locale > settings and so would be different on different machines? No, date literals using the # syntax are always #mm/dd/yyyy# format; try coding: d=#2006-10-19# and watch what happens (note that I'm not saying that was the best choice for VB to implement - just that it is reliable) > Personally I prefer the unambiguous format yyyymmdd. No argument from me on that (except that it's usually yyyy-mm-dd, especially in SQL queries). -- Reply to the group so all can participate VB.Net: "Fool me once..."
|
Next
|
Last
Pages: 1 2 3 Prev: Error 480 - can't create autoredraw image Next: VB6 FileCopy Fails Windows XP SP2 |