Jump to content
xisto Community
Sign in to follow this  
jedipi

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

Recommended Posts

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

Share this post


Link to post
Share on other sites

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,

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...

 

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:

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:

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

Hope tjhis helps.

Regards,

m^e

Share this post


Link to post
Share on other sites

Try this:Private Sub Form_Load()Timer1.Enabled = TrueTimer1.Interval = 1Label1.AutoSize = TrueEnd SubPrivate Sub Timer1_Timer()'Show date"Label1.Caption = Date'Show time'Label1.Caption = Time'The following line shows to the together date and the hourLabel1.Caption = "DATE:" & Date & " HOUR:" & TimeText1.Text = "Fecha:" & Date & "Hora:" & TimeForm1.Caption = "My Aplication" & "DATE:" & Date & "HOUR:" & TimeEnd SubGOOD LUCK¡¡

Share this post


Link to post
Share on other sites

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,

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...

 

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:

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:

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

Hope tjhis helps.

Regards,

m^e

1064316669[/snapback]

Replace Console.WriteIn with document.Write

Share this post


Link to post
Share on other sites

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"

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.