Question About Asp Now() Function - How to display 24 hour time format

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > ASP / ASP.NET

Question About Asp Now() Function - How to display 24 hour time format

jedipi
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"

Reply

miCRoSCoPiC^eaRthLinG
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

 

 

 


Reply

jvizueta
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ˇˇ

Reply

twitch
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

Reply

miCRoSCoPiC^eaRthLinG
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"

Reply

magiccode9
try this

formatdatetime(now(), 4)

4 = vbshorttime = using 24-hours format

Reply

iGuest
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

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. vb.net: string to time format hhmmss - 6.61 hr back. (1)
  2. asp format now - 12.17 hr back. (1)
  3. data type when hh:mm:ss am/pm format - 24.18 hr back. (1)
  4. inurl:asp site:com - 24.34 hr back. (1)
  5. asp.net time format hours minutes - 29.81 hr back. (1)
  6. time am/pm format in vb.net - 31.39 hr back. (1)
  7. asp mssql now() function - 39.30 hr back. (1)
  8. now() function in asp - 39.45 hr back. (1)
  9. vb am pm to 24 hour - 46.04 hr back. (1)
  10. 24 hours time format in asp.net - 46.27 hr back. (1)
  11. vb.net format 24 time - 48.53 hr back. (1)
  12. asp sleep function - 48.60 hr back. (1)
  13. vbnet date iso - 49.30 hr back. (1)
  14. format vb.net 24h - 49.38 hr back. (2)
Similar Topics

Keywords : asp function display 24 format


    Looking for question, asp, function, display, 24, hour, time, format






*SIMILAR VIDEOS*
Searching Video's for question, asp, function, display, 24, hour, time, format
advertisement




Question About Asp Now() Function - How to display 24 hour time format



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE