[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 520
  • Last Modified:

Where can I get free ASP code for a clock with only hh:ss AM/PM ?

Hi Experts,

Where can I get free ASP code for a clock with only hh:ss AM/PM ?

Thanks
0
indyng
Asked:
indyng
  • 2
1 Solution
 
Anthony PerkinsCommented:
Again you have three options:
1. Hope the Regional Settings are set correctly on the server and use something like this: FormatDateTime(Now(), vbLongTime)
2. Write a function to output in the format you need.
3. Use ASP.NET

For option 2, see the code I posted in your related question:
http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21788965.html
0
 
Anthony PerkinsCommented:
In case you could not figure it out here it is:

Function GetCurrentTime()
Dim Dat, AMPM

Dat = Now()

If Hour(Dat) < 12 Then
      AMPM = " AM"
Else
      AMPM = " PM"
End If

GetCurrentTime = LPad((Hour(Dat) - 1) Mod 12 + 1) & ":" & LPad(Minute(Dat)) & AMPM

End Function

Function LPad(ByVal Value)

LPad = Right("0" & CStr(Value), 2)

End Function
0
 
hongjunCommented:
Or are you want to use JavaScript?


<html>

<head>

<script language="JavaScript">
<!--

/*
Live Date Script-
*/


var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='000000' size='1' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</b></font></small>"
//if (document.all)
document.getElementById('clock').innerHTML=cdate
//else
//document.write(cdate)
}
//if (!document.all)
//getthedate()
function goforit(){
//if (document.all)
setInterval("getthedate()",1000)
}

//-->
</script>

</head>

<body onload="goforit()">
<span id="clock"></span>
</body>

</html>


----
hongjun
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now