Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Question About Asp Now() Function, How to display 24 hour time format
jedipi
post Aug 2 2005, 08:21 AM
Post #1


Premium Member
Group Icon

Group: Members
Posts: 352
Joined: 2-March 05
From: Australia
Member No.: 2,859



I am learning asp currently.
The learning environment is windows 2003 plus the builtin IIS.
Time format in this machine is set to 24 hours format (hh:mm:ss).

However, when i call the Now() function in a ASP script, the time it caught and
displayed as "2005-7-29 7:32:40pm".

Is there anyway to make it displayed in 24 hours format.??
Just like this "2005-7-29 19:32:40"
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Aug 2 2005, 11:40 AM
Post #2


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411
myCENTs:84.36



I'm going to reply to this from a VB.NET perspective - but it should work with ASP.NET too - coz both employ same libraries.. almost.

You have to use the Format function to reformat your date time string.

For example,
CODE

Console.Writeln ( Format ( Now(), "hh:MM:ss tt" ) )

will produce an output in the AM/PM format - the tt part denotes the AM/PM. If you omit that, the time is shown in 24hour format. So your code should be...

CODE

Console.Writeln ( Format ( Now(), "hh:MM:ss" ) )

This should give you the desired output. Be careful, the minute part of the time has to be denoted with capital MM - the small mm stands for the month.

For example to get a complete date time in the ISO format, you should use a string like this:
CODE

Console.Writeln ( Format ( Now(), "yyyy/mm/dd hh:mm:ss" ) )


If you use mmmm instead of "mm" then you get the expanded month name in english - i.e. to get a display like 27 January, 200 you should use a format string like:
CODE

Console.Writeln ( Format ( Now(), "dd mmmm, yyyy" ) )


Hope tjhis helps.
Regards,
m^e
Go to the top of the page
 
+Quote Post
jvizueta
post Sep 24 2005, 12:29 AM
Post #3


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 22
Joined: 13-September 05
Member No.: 8,434



Try this:


Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1
Label1.AutoSize = True
End Sub

Private Sub Timer1_Timer()
'Show date"
Label1.Caption = Date

'Show time
'Label1.Caption = Time

'The following line shows to the together date and the hour

Label1.Caption = "DATE:" & Date & " HOUR:" & Time

Text1.Text = "Fecha:" & Date & "Hora:" & Time

Form1.Caption = "My Aplication" & "DATE:" & Date & "HOUR:" & Time

End Sub

GOOD LUCKˇˇ
Go to the top of the page
 
+Quote Post
twitch
post Oct 4 2005, 03:22 PM
Post #4


Veteran Nut
Group Icon

Group: Members
Posts: 527
Joined: 4-October 05
From: UK
Member No.: 8,895



QUOTE(microscopic^earthling @ Aug 2 2005, 11:40 AM)
I'm going to reply to this from a VB.NET perspective - but it should work with ASP.NET too - coz both employ same libraries.. almost.

You have to use the Format function to reformat your date time string.

For example,
CODE

Console.Writeln ( Format ( Now(), "hh:MM:ss tt" ) )

will produce an output in the AM/PM format - the tt part denotes the AM/PM. If you omit that, the time is shown in 24hour format. So your code should be...

CODE

Console.Writeln ( Format ( Now(), "hh:MM:ss" ) )

This should give you the desired output. Be careful, the minute part of the time has to be denoted with capital MM - the small mm stands for the month.

For example to get a complete date time in the ISO format, you should use a string like this:
CODE

Console.Writeln ( Format ( Now(), "yyyy/mm/dd hh:mm:ss" ) )


If you use mmmm instead of "mm" then you get the expanded month name in english - i.e. to get a display like 27 January, 200 you should use a format string like:
CODE

Console.Writeln ( Format ( Now(), "dd mmmm, yyyy" ) )


Hope tjhis helps.
Regards,
m^e
*


Replace Console.WriteIn with document.Write
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Oct 21 2005, 05:26 PM
Post #5


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411
myCENTs:84.36



Also I forgot to mention last time,

hh:mm:ss tt gives you the output in 12hour format, where
hh = hour
mm = minutes
ss = seconds
tt = AM/PM

whereas,
HH:mm:ss gives you output in 24hour format. So the difference lies in CAPITAL "HH " and SMALL "hh"
Go to the top of the page
 
+Quote Post
magiccode9
post Nov 7 2005, 02:58 PM
Post #6


Advanced Member
Group Icon

Group: [HOSTED]
Posts: 123
Joined: 7-November 05
Member No.: 9,489



try this

formatdatetime(now(), 4)

4 = vbshorttime = using 24-hours format
Go to the top of the page
 
+Quote Post
iGuest
post Jun 14 2008, 08:23 AM
Post #7


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



How to get totalt minutes in datacolumn Total
Question About Asp Now() Function

Hi,



I want to get total minutes in my datacloumn name "Total" i9t given me the correct # when I put hours eg( 2.00pm to 10.00pm total come to 480" but the problem comes when I try to enter 4.00 to 4.30 it is not showing the correct #. Please help below append is my code. Thank in advance



Dim dt As New DataTable()

Dim ds As New DataSet()



dt = New DataTable("dt1")

Dim dt1 As New DataColumn()

dt1.ColumnName = "FromTime"

'dt1.DataType = Type.GetType("System.Double", 2)

dt1.DataType = (GetType(Decimal))

dt.Columns.Add(dt1)

DataGridView1.DataSource = dt

DataGridView1.Visible = True





Dim dt2 As New DataColumn

dt2.ColumnName = "ToTime"

' dt2.DataType = Type.GetType("System.Double", 2)

dt2.DataType = (GetType(Decimal))

dt.Columns.Add(dt2)

DataGridView1.DataSource = dt





Dim dt3 As New DataColumn()

dt3.ColumnName = "Total"

' dt3.DataType = Type.GetType("System.Double", 2)

dt3.DataType = (GetType(Decimal))

dt3.Expression = "totime*60 - fromtime *60 "

dt.Columns.Add(dt3)

DataGridView1.DataSource = dt



-question by Umesh
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Google Calendar Question(4)
  2. How Do I Get Rid Of Warn: (0%) ----- ?(9)
  3. Time Travel?(4)
  4. How To Include A File Using Absolute Paths Under A Secure Php Installation(6)
  5. Classics: Albion(0)
  6. What Is Mkv? Need Help With This File Format?(10)
  7. Using The Php Mail() Function For Images Or Attachments(6)
  8. Time Functions Needed(9)
  9. Ask An Open Question 404 (and A Confused Noob)(3)
  10. Sleep Function Not Working(4)
  11. Password Function(0)
  12. Question Related To Website(5)
  13. Task Mgr. Has Been Disabled By Your Administrator(7)
  14. How To Make Both Windows Look Like Active At Same Time(9)
  15. Concept Of Hijaab In Islaam(2)
  1. IE6 display:block hides other image BUG(1)
  2. [.net]matchall Function(0)
  3. Pointers(0)
  4. What's The Best CMS(38)
  5. Question: Ssh Tunneling(1)
  6. Preventing Spam When Using Php's Mail Function(6)
  7. New Nvidia Display Driver Was Released On 1/6(2)
  8. Do Google Search Better Than Yahoo?(15)
  9. Back After Long Time(1)
  10. Disable Display Properties Tabs(3)
  11. Simple Java Question(3)
  12. How To: Display A Members/user List.(3)
  13. Css Minus The <p>(9)
  14. MySQL Output Database Question(18)
  15. Mp3 Questions(14)


 



- Lo-Fi Version Time is now: 5th December 2008 - 12:20 AM