how do i make time and date like this???
Friday, July 7, 2006 by supr4 | Discussion: DesktopX


does anyone know how to make time and date like this with desktop X? if do, can u like give me a simple guide or something...or if anyone has time, can they make me one..not really pro with computers...thanks..
BTW, THE PICTURS ABOVE IS FROM A MEMBER NAMED "THREI" so THREI if u don't like that i used ur picture for example u can tell me to take it off!! or if ur kind enough to help me make one
Reply #2 Tuesday, July 11, 2006 4:47 PM
PS. Also, a good source of information is to download Microsoft's WSH Help File which includes both vbs & jscript references as well. Using search you will get an abundant amount of date/time example codes.
Reply #3 Tuesday, July 11, 2006 5:29 PM
You need to add in some timers to update the date ever few mins, and the time every second (if you want seconds).
There are lots of tuts out there on timers.
Enjoy
Reply #5 Wednesday, July 12, 2006 3:27 AM
Here is what the Date object script would look like with a 10 second timer added:
Sub Object_OnScriptEnter
object.SetTimer 1, 10000 '---(a ten second timer starts as soon as the object loads up)
End Sub
Sub object_ontimer1
Dim d
d= day(date)
Object.text= d
End Sub
Just do the same for the other objects as well.
Okay, now for the Time object.
When I looked for the vbscript code for time I found that it always displays the seconds and the AM/PM with it. That’s not how the 1st picture appears. So it seems I had to splice everything up. In total there are 3 text objects. Again, they would be positioned and grouped.
1. The hour (plus the colon)
2. The minutes
3. am/pm
The Hour object (* since the hour function returns the hours from 0 – 23 instead of 1 – 12 I had to put in the hours myself using Select Case)
Sub Object_onscriptenter
object.SetTimer 1, 1000'---a one-second timer starts as soon as the object loads up
End Sub
Sub object_ontimer1
Dim h
h = hour(now)
Select Case h '-the following checks the hours (0-23) and changes the text to the hours 1-12 accordingly
Case 0
Object.text= "12:"
Case 1
object.text= "1:"
Case 2
object.text= "2:"
Case 3
object.text= "3:"
Case 4
object.text= "4:"
Case 5
object.text= "5:"
Case 6
object.text= "6:"
Case 7
object.text= "7:"
Case 8
object.text= "8:"
Case 9
object.text= "9:"
Case 10
object.text= "10:"
Case 11
object.text= "11:"
Case 12
object.text= "12:"
Case 13
object.text= "1:"
Case 14
object.text= "2:"
Case 15
object.text= "3:"
Case 16
object.text= "4:"
Case 17
object.text= "5:"
Case 18
object.text= "6:"
Case 19
object.text= "7:"
Case 20
object.text= "8:"
Case 21
object.text= "9:"
Case 22
object.text= "10:"
Case 23
object.text= "11:"
End Select
End Sub
----------------------
The Minute object
Sub Object_onscriptenter
object.SetTimer 1, 1000
End Sub
Sub object_ontimer1
Dim m
m = minute(now)
object.text = m
End Sub
---------------------------
The AM/PM object
Sub Object_onscriptenter
object.SetTimer 1, 1000
End Sub
Sub object_ontimer1'---the following checks the hours (0 – 23). Anything less than 11 is AM. Anything greater than 11 is PM
Dim h
h = hour(now)
If h <= 11 Then
object.text = "AM "
ElseIf h >11 Then
Object.text= "PM"
End If
End Sub
That’s all there is to that!
Reply #6 Wednesday, July 12, 2006 7:14 AM
Dim m
m = month(date)
MonthName(m, True)
(ref: http://www.w3schools.com/vbscript/func_monthname.asp)
And instead of the select statement to get AM and PM hours you can do:
Dim h
h = hour(FormatDateTime(now, 3)) & ":"
FormatDateTime(now, 3) return the current time in AM PM format.
(ref: http://www.w3schools.com/vbscript/func_formatdatetime.asp)
Reply #7 Wednesday, July 12, 2006 10:58 AM
So now the month script looks like this:
Sub Object_onscriptenter
object.SetTimer 1, 10000
End Sub
Sub object_ontimer1
Dim m
m = month(date)
mo= MonthName (m, True)
object.text= mo
End Sub
------------
And the Hour script looks like this:
Sub Object_onscriptenter
object.SetTimer 1, 1000
End Sub
Sub object_ontimer1
Dim h
h = hour (FormatDateTime(now, 3))& ":"
object.text = h
End Sub
I guess we solved this question! Thanks to all the forumers who stopped by to help. (Now, I wonder if supr4 is even still making this object?)
Reply #8 Wednesday, July 12, 2006 11:03 AM
Any ideas?
Reply #9 Wednesday, July 12, 2006 11:19 AM
Reply #10 Wednesday, July 12, 2006 11:20 AM
Let give it another go:
Sub Object_onscriptenter
object.SetTimer 1, 1000
End Sub
Sub object_ontimer1
Dim m
m = minute(now)
If Len(m) = 1 Then m = "0" & m
object.text = m
End Sub
Reply #11 Wednesday, July 12, 2006 3:27 PM
But it is now after noon and the hour object still displays in the 23 hour format. I'm not sure what I did wrong. I used exactly the code posted above.
Reply #12 Wednesday, July 12, 2006 4:35 PM
Dim h
h = Hour(Now())
If h > 12 Then h = h - 12
Object.Text = h & ":"
Reply #13 Wednesday, July 12, 2006 9:02 PM

Reply #14 Wednesday, July 19, 2006 6:53 AM
Sub Object_OnTimer1
Object.Text = FormatDateTime(Time(),4)
End Sub
This will produce an output like: "11:52"
Reply #15 Wednesday, July 19, 2006 1:07 PM
Question: Is there any way to set the time/date to somewhere else in the world-- a specific country? I kinda had an idea for a widget.....
UPDATE: It is now after noon and it is back to the 23 hour time format....
Reply #16 Wednesday, July 19, 2006 7:57 PM
As for returning a different country, you have to find the timezone and then adjust that according to the time zone difference. Use DateAdd to add the number of hours you need. ref: http://www.w3schools.com/vbscript/func_dateadd.asp
To further comlicate it, it seems that there is no function in VBScript that returns the time for a standard timezone such as GTM. So you have to find out what time zone you are in and then calculate the difference accoring to that.
Reply #17 Monday, July 24, 2006 2:57 AM
Reply #18 Monday, July 24, 2006 3:02 AM
Reply #19 Monday, July 24, 2006 3:07 AM
Reply #20 Monday, July 24, 2006 6:36 PM
I came across this problem (*The math is according to my time for now.):
t= time
desktopx.Object("gmt").text= "Greenwich Time " &(DateAdd("h",8,(t)))
desktopx.Object("utc+1").text= "UTC+1 " &(DateAdd("h",9,(t)))
The 2nd line returns the time : 11:00:00 pm
The 3rd line returns: 12/31/1899 12:00:00 am
Any thoughts on why the 3rd line returns an incorrect date along with the time?
Also: I'll be creating another thread as soon as the forums start working. (since I've unintentionally taken this one off-topic)
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!







Reply #1 Monday, July 10, 2006 5:32 PM
If it’s for your own personal use then read on.
This is what I figured on my own. It could be a specific type of font that makes certain letters lower than others (wild guess). But, for sure if you want it to look exactly like that you would need that font.
In the second picture it looks like there could be 3 different objects
1.Date
2.Weekday
3.Month
Each of them would be positioned higher or lower and then grouped.
You would go to the ‘states’ tab in the properties and change the object from ‘image’ to ‘text’
Insert the scripts below to their respective objects.
The Date object:
Dim d
d= day(date)
Object.text= d
------------------------------
The Weekday object:
Dim dy
dy= WeekdayName(Weekday(Date),true) ‘---This will make the weekday appear abbreviated. For the full name remove ‘,true’ from the parenthesis.
Object.text = dy
-------------------------------
The Month object:
Dim m
m = month(date)
Select Case m’—The following checks what month it is and changes the object text accordingly
Case 1
object.text= “Jan”
case 2
object.text= “Feb”
case 3
object.text= “Mar”
case 4
object.text= “Apr”
case 5
object.text= “May”
case 6
object.text= “Jun”
case 7
object.text= “Jul”
case 8
object.text= “Aug”
case 9
object.text= “Sept”
case 10
object.text= “Oct”
case 11
object.text= “Nov”
case 12
object.text= “Dec”
End Select
----------------------
Don't have much time now so I’ll get back to you later on the time object.
For more info on vbscript functions like weekday, date, etc, go to W3Schools ----
[link="http://www.w3schools.com/vbscript/vbscript_ref_functions.asp"]http://www.w3schools.com/vbscript/vbscript_ref_functions.asp">Link
Hope this helps.