|
|
|
|
![]() ![]() |
Aug 2 2005, 08:21 AM
Post
#1
|
|
|
Premium Member 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" |
|
|
|
Aug 2 2005, 11:40 AM
Post
#2
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 |
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 |
|
|
|
Sep 24 2005, 12:29 AM
Post
#3
|
|
|
Newbie [ Level 2 ] 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ˇˇ |
|
|
|
Oct 4 2005, 03:22 PM
Post
#4
|
|
|
Veteran Nut 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 |
|
|
|
Oct 21 2005, 05:26 PM
Post
#5
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 |
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" |
|
|
|
Nov 7 2005, 02:58 PM
Post
#6
|
|
|
Member [ Level 2 ] Group: [HOSTED] Posts: 61 Joined: 7-November 05 Member No.: 9,489 |
try this
formatdatetime(now(), 4) 4 = vbshorttime = using 24-hours format |
|
|
|
Jun 14 2008, 08:23 AM
Post
#7
|
|
|
Newbie [ Level 1 ] 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 |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 7th September 2008 - 11:09 PM |