Author |
Topic |
RebelTech
Average Member
USA
613 Posts |
Posted - 11 October 2003 : 21:13:59
|
In using the code that I constructed from the internet, it works in an .asp by itself but, when I put it in the footer I get this error: The only problem with the inet code by itself is that it reports 24: hours instead of 00: hours as it should be. (error while in footer)
Illegal assignment: 's'
/forum/inc_footer.asp, line 85
I am not sure why the footer killed it but, it seems both scripts are not handling the offset when the result = 24 / 00 hours.
|
Edited by - RebelTech on 11 October 2003 21:17:55 |
|
|
RebelTech
Average Member
USA
613 Posts |
Posted - 11 October 2003 : 21:36:01
|
I tested a little. Here is what I found. I decreased the offset (was +4) till utc was 22:. I then increased offset by 1 each test. 22: hours - ok, 23: hours -ok, next increase - error |
|
|
RebelTech
Average Member
USA
613 Posts |
Posted - 11 October 2003 : 21:53:50
|
further update: it is not just the 00 or 24 hour that is killing it. No matter what offset I use if the result goes to or past 00/24 it errors out. I assume that since my offset should be 4 that it will not work until the clock at my server hits midnight and then it is good for 20 hours. |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
Posted - 11 October 2003 : 23:35:49
|
That's a good one that I hadn't thought about either.
Here's the new code, using Altis' forelast example (the last one errors out on me big time):
Dim strTimeNow, strHourNow, strMinNow, strSecNow
strHourNow = Hour(Now())
strMinNow = Minute(Now())
strSecNow = Second(Now())
If Len(strSecNow)=0 Then
strSecNow = "00"
ElseIf Len(strSecNow)=1 Then
strSecNow = "0" & strSecNow
End If
strTimeOffset = 7
strNewTime = (strHourNow - strTimeOffset)
if strNewTime < 0 then
strNewTime = strNewTime + 24
end if
strTimeNow = strNewTime & ":" & strMinNow
strTimeNow = FormatDateTime(strTimeNow, vbShortTime) & ":" & strSecNow The lines that I added or where I changed something are in red. I've tested this and it works |
|
|
RebelTech
Average Member
USA
613 Posts |
Posted - 12 October 2003 : 00:06:49
|
Still get the error: (Type mismatch: 'FormatDateTime'
/forum/inc_footer.asp, line 95 )
My offset is +4 As long as it was subtracting it seemed ok. I didn't push it though. But, here in Texas we are -5 from UTC. My server is -4 from UTC. So I need to add 4 to get back to UTC. Here is your code with my offset.
Dim strTimeNow, strHourNow, strMinNow, strSecNow
strHourNow = Hour(Now())
strMinNow = Minute(Now())
strSecNow = Second(Now())
If Len(strSecNow)=0 Then
strSecNow = "00"
ElseIf Len(strSecNow)=1 Then
strSecNow = "0" & strSecNow
End If
strTimeOffset =4
strNewTime = (strHourNow + strTimeOffset)
if strNewTime < 0 then
strNewTime = strNewTime + 24
end if
strTimeNow = strNewTime & ":" & strMinNow
strTimeNow = FormatDateTime(strTimeNow, vbShortTime) & ":" & strSecNow |
|
|
RebelTech
Average Member
USA
613 Posts |
Posted - 12 October 2003 : 00:12:12
|
(strTimeNow, vbShortTime)
Is the error because after adding to strTimeNow it is no longer a date object? In RB we would have ParseDate() I think. |
Edited by - RebelTech on 12 October 2003 00:13:15 |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
Posted - 12 October 2003 : 00:17:11
|
Try this... change the following part
if strNewTime < 0 then
strNewTime = strNewTime + 24
end if to this:
if strNewTime < 0 then
strNewTime = strNewTime + 24
elseif strNewTime > 23 then
strNewTime = strNewTime - 24
end if |
|
|
RebelTech
Average Member
USA
613 Posts |
Posted - 12 October 2003 : 00:37:27
|
You sir appear to be a vb guru. This one went just fine. I learned a lot from this session and i feel more confident in wading into my forum files and mutilating the hec out of them Really, thanks and I enjoyed the lessons I learned. I am anxious to keep an eye on it for the day or so. How will it report 00 UTC? As 00 or 24? Would there have been a problem in the previous incarnation if I would have just subtracted enough hours to get UTC? I gotta say thanks again. |
|
|
RebelTech
Average Member
USA
613 Posts |
Posted - 12 October 2003 : 00:39:33
|
I need to learn what a carriage returns is! |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
Posted - 12 October 2003 : 00:43:42
|
midnight will be shown as 00:00:00 you could've subtracted 20 hours instead of adding 4 hours, but with the codes as they are now, with the last bit of code included, it can be used by anyone whether they need to add or subtract hours
Since this is now a MOD including the necessary codes, I'll move this topic to the MOD W/ Code forum |
|
|
RebelTech
Average Member
USA
613 Posts |
Posted - 12 October 2003 : 00:46:59
|
Hec, I am tempted to put all kinds of times all over my forum now! |
|
|
cyber Knight
Starting Member
41 Posts |
Posted - 12 October 2003 : 10:11:50
|
how about
<%= Now() %>
|
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
Posted - 12 October 2003 : 11:09:28
|
quote: Originally posted by cyber Knight
how about
<%= Now() %>
And how do you suppose that'll help display the time with a certain offset? Please try reading all posts in a topic before you make a reply like that. |
|
|
cyber Knight
Starting Member
41 Posts |
Posted - 12 October 2003 : 14:27:11
|
SIR ,I was simply commenting on rebeltech's reply. some users like to know that too.
since we got off topic a little ,chkout this :
ASP clocks
I guess the next reply will be something that might goes like "" hey C.K get your head out of your........""
|
|
|
Topic |
|