473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

AM PM does not appear on page

I wonder if any of you have had this problem before. I have a variable dt
which reads the scmalldatetime field in the database. I want to show the
date & time on aspx page in the format 'dd/MM/yyyy hh:mm tt' using this
statement:

dt.ToString("dd/MM/yyyy hh:mm tt")

But the AMPM designators does not appear. Other parts of the date & time can
be determined using the format string except the AMPM designator. The
regional setting of both my pc and the server have the AM PM symbol set
correctly.

I've even tried hard-coded the time to show be shown the page like this:

Dim dt As DateTime = #10/5/1971 5:38:00 PM#
Dim sdt As String = dt.ToString("dd/MM/yyyy hh:mm tt")
lblDateTaken.Text = sdt

And the date is shown as 05/10/1971 05:38

Is there anything I should do to make them appear the way I want?

thx
----------------------------------------------------------------------------
---- -----------------------------------------------------------------------
---------
Nov 18 '05 #1
9 3299
Hi Razak,

You want the Format function to get what you need:

Dim dt As DateTime = #10/5/1971 5:38:00 PM#
Dim sdt As String '= dt.ToString("dd/MM/yyyy hh:mm tt")
sdt = Format(dt, "dd/MM/yyyy hh:mm tt")
lblDateTaken.Text = sdt

Returns 05/10/1971 05:38 PM

http://msdn.microsoft.com/library/de...ateformats.asp

Does this help?

Ken
Microsoft MVP [ASP.NET]
"Razak" <ra***@mmsc.com.my> wrote in message
news:ui**************@TK2MSFTNGP12.phx.gbl...
I wonder if any of you have had this problem before. I have a variable dt
which reads the scmalldatetime field in the database. I want to show the
date & time on aspx page in the format 'dd/MM/yyyy hh:mm tt' using this
statement:

dt.ToString("dd/MM/yyyy hh:mm tt")

But the AMPM designators does not appear. Other parts of the date & time
can
be determined using the format string except the AMPM designator. The
regional setting of both my pc and the server have the AM PM symbol set
correctly.

I've even tried hard-coded the time to show be shown the page like this:

Dim dt As DateTime = #10/5/1971 5:38:00 PM#
Dim sdt As String = dt.ToString("dd/MM/yyyy hh:mm tt")
lblDateTaken.Text = sdt

And the date is shown as 05/10/1971 05:38

Is there anything I should do to make them appear the way I want?

thx
----------------------------------------------------------------------------
---- -----------------------------------------------------------------------
---------


Nov 18 '05 #2
Nope.. they still does not appear...
It still shows : 05/10/1971 05:38
----------------------------------------------------------------------------
---- -----------------------------------------------------------------------
---------
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Razak,

You want the Format function to get what you need:

Dim dt As DateTime = #10/5/1971 5:38:00 PM#
Dim sdt As String '= dt.ToString("dd/MM/yyyy hh:mm tt")
sdt = Format(dt, "dd/MM/yyyy hh:mm tt")
lblDateTaken.Text = sdt

Returns 05/10/1971 05:38 PM

http://msdn.microsoft.com/library/de...ateformats.asp
Does this help?

Ken
Microsoft MVP [ASP.NET]
"Razak" <ra***@mmsc.com.my> wrote in message
news:ui**************@TK2MSFTNGP12.phx.gbl...
I wonder if any of you have had this problem before. I have a variable dt
which reads the scmalldatetime field in the database. I want to show the
date & time on aspx page in the format 'dd/MM/yyyy hh:mm tt' using this
statement:

dt.ToString("dd/MM/yyyy hh:mm tt")

But the AMPM designators does not appear. Other parts of the date & time
can
be determined using the format string except the AMPM designator. The
regional setting of both my pc and the server have the AM PM symbol set
correctly.

I've even tried hard-coded the time to show be shown the page like this:

Dim dt As DateTime = #10/5/1971 5:38:00 PM#
Dim sdt As String = dt.ToString("dd/MM/yyyy hh:mm tt")
lblDateTaken.Text = sdt

And the date is shown as 05/10/1971 05:38

Is there anything I should do to make them appear the way I want?

thx
--------------------------------------------------------------------------

--
---- ---------------------------------------------------------------------

--
---------

Nov 18 '05 #3

"Razak" <ra***@mmsc.com.my> wrote in message news:ui**************@TK2MSFTNGP12.phx.gbl...
I wonder if any of you have had this problem before. I have a variable dt
which reads the scmalldatetime field in the database. I want to show the
date & time on aspx page in the format 'dd/MM/yyyy hh:mm tt' using this
statement:

dt.ToString("dd/MM/yyyy hh:mm tt")

But the AMPM designators does not appear. Other parts of the date & time can
be determined using the format string except the AMPM designator. The
regional setting of both my pc and the server have the AM PM symbol set
correctly.


the "tt" format is specified (in MSDN) as

The AM/PM designator defined in AMDesignator or PMDesignator, if any.

(that's a "DateTimeFormatInfo.AMDesignator")

could it be that you (or rather the aspnet process) use a culture that doesn't
have an AMDesignator (or an empty one)?
What it the value of DateTimeInfo.CurrentInfo.AMDesignator ?
Hans Kesting
Nov 18 '05 #4
It appears that the AMDesignator and PMDesignator is empty. How to set it
since they are read-only?

On the server, I've set the designators accordingly in the Regional
settings.

----------------------------------------------------------------------------
---- -----------------------------------------------------------------------
---------
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...

"Razak" <ra***@mmsc.com.my> wrote in message news:ui**************@TK2MSFTNGP12.phx.gbl...
I wonder if any of you have had this problem before. I have a variable dt which reads the scmalldatetime field in the database. I want to show the
date & time on aspx page in the format 'dd/MM/yyyy hh:mm tt' using this
statement:

dt.ToString("dd/MM/yyyy hh:mm tt")

But the AMPM designators does not appear. Other parts of the date & time can be determined using the format string except the AMPM designator. The
regional setting of both my pc and the server have the AM PM symbol set
correctly.


the "tt" format is specified (in MSDN) as

The AM/PM designator defined in AMDesignator or PMDesignator, if any.

(that's a "DateTimeFormatInfo.AMDesignator")

could it be that you (or rather the aspnet process) use a culture that

doesn't have an AMDesignator (or an empty one)?
What it the value of DateTimeInfo.CurrentInfo.AMDesignator ?
Hans Kesting

Nov 18 '05 #5

"Razak" <ra***@mmsc.com.my> wrote in message news:Ok**************@TK2MSFTNGP10.phx.gbl...
It appears that the AMDesignator and PMDesignator is empty. How to set it
since they are read-only?

On the server, I've set the designators accordingly in the Regional
settings.


IIRC, the regional settings are user-specific. So if *you* set them (using *your* account)
then the ASPNET user ('NETWORK SERVICES' for Win2003?) still uses it's original
version.

Do you change the "culture" somewhere in your application?

Try this:
dt.ToString("dd/MM/yyyy hh:mm tt", DateTimeFormatInfo.InvariantInfo);

Hans Kesting
Nov 18 '05 #6
Nope, I didnt change any culture anywhere in my app. Anyway, I have found
the way to customize the am/pm designator. It's based on the current thread
though, so I have to put then code in a function and call it whenever I need
to display the formatted date & time.

Public Shared Function GetDateTimeString(ByVal dt As Date) As String
Dim myOCI, myCCI As CultureInfo

myCCI = myOCI.CurrentCulture().Clone()
myCCI.DateTimeFormat.PMDesignator = "pm"
myCCI.DateTimeFormat.AMDesignator = "am"
Thread.CurrentThread.CurrentCulture = myCCI

Return Format(dt, "dd/MM/yyyy hh:mm tt")
End Function

Thanks for your response..
----------------------------------------------------------------------------
---- -----------------------------------------------------------------------
---------
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:OU**************@TK2MSFTNGP10.phx.gbl...

"Razak" <ra***@mmsc.com.my> wrote in message news:Ok**************@TK2MSFTNGP10.phx.gbl...
It appears that the AMDesignator and PMDesignator is empty. How to set it since they are read-only?

On the server, I've set the designators accordingly in the Regional
settings.


IIRC, the regional settings are user-specific. So if *you* set them (using

*your* account) then the ASPNET user ('NETWORK SERVICES' for Win2003?) still uses it's original version.

Do you change the "culture" somewhere in your application?

Try this:
dt.ToString("dd/MM/yyyy hh:mm tt", DateTimeFormatInfo.InvariantInfo);
Hans Kesting

Nov 18 '05 #7
Curious.

You might want to use this to determine what culture your system is set to.

lblDateTaken.Text = Thread.CurrentThread.CurrentCulture.EnglishName & _
":" & Thread.CurrentThread.CurrentUICulture.EnglishName

Ken
"Razak" <ra***@mmsc.com.my> wrote in message
news:e5**************@TK2MSFTNGP12.phx.gbl...
Nope, I didnt change any culture anywhere in my app. Anyway, I have found
the way to customize the am/pm designator. It's based on the current
thread
though, so I have to put then code in a function and call it whenever I
need
to display the formatted date & time.

Public Shared Function GetDateTimeString(ByVal dt As Date) As String
Dim myOCI, myCCI As CultureInfo

myCCI = myOCI.CurrentCulture().Clone()
myCCI.DateTimeFormat.PMDesignator = "pm"
myCCI.DateTimeFormat.AMDesignator = "am"
Thread.CurrentThread.CurrentCulture = myCCI

Return Format(dt, "dd/MM/yyyy hh:mm tt")
End Function

Thanks for your response..
----------------------------------------------------------------------------
---- -----------------------------------------------------------------------
---------
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:OU**************@TK2MSFTNGP10.phx.gbl...

"Razak" <ra***@mmsc.com.my> wrote in message

news:Ok**************@TK2MSFTNGP10.phx.gbl...
> It appears that the AMDesignator and PMDesignator is empty. How to set it > since they are read-only?
>
> On the server, I've set the designators accordingly in the Regional
> settings.
>


IIRC, the regional settings are user-specific. So if *you* set them
(using

*your* account)
then the ASPNET user ('NETWORK SERVICES' for Win2003?) still uses it's

original
version.

Do you change the "culture" somewhere in your application?

Try this:
dt.ToString("dd/MM/yyyy hh:mm tt",

DateTimeFormatInfo.InvariantInfo);

Hans Kesting



Nov 18 '05 #8
It's Date taken: Malay (Malaysia):English (United States)

I remember setting my server to Malay(Malaysia) before, but have changed it
to English(UK).
Could that be the problem? Perhaps Malay culture setting has no AM/PM
Designators set.

----------------------------------------------------------------------------
---- -----------------------------------------------------------------------
---------
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:eY**************@TK2MSFTNGP09.phx.gbl...
Curious.

You might want to use this to determine what culture your system is set to.
lblDateTaken.Text = Thread.CurrentThread.CurrentCulture.EnglishName & _ ":" & Thread.CurrentThread.CurrentUICulture.EnglishName

Ken
"Razak" <ra***@mmsc.com.my> wrote in message
news:e5**************@TK2MSFTNGP12.phx.gbl...
Nope, I didnt change any culture anywhere in my app. Anyway, I have found the way to customize the am/pm designator. It's based on the current
thread
though, so I have to put then code in a function and call it whenever I
need
to display the formatted date & time.

Public Shared Function GetDateTimeString(ByVal dt As Date) As String
Dim myOCI, myCCI As CultureInfo

myCCI = myOCI.CurrentCulture().Clone()
myCCI.DateTimeFormat.PMDesignator = "pm"
myCCI.DateTimeFormat.AMDesignator = "am"
Thread.CurrentThread.CurrentCulture = myCCI

Return Format(dt, "dd/MM/yyyy hh:mm tt")
End Function

Thanks for your response..
--------------------------------------------------------------------------

--
---- ---------------------------------------------------------------------

--
---------
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:OU**************@TK2MSFTNGP10.phx.gbl...

"Razak" <ra***@mmsc.com.my> wrote in message

news:Ok**************@TK2MSFTNGP10.phx.gbl...
> It appears that the AMDesignator and PMDesignator is empty. How to
set it
> since they are read-only?
>
> On the server, I've set the designators accordingly in the Regional
> settings.
>

IIRC, the regional settings are user-specific. So if *you* set them
(using

*your* account)
then the ASPNET user ('NETWORK SERVICES' for Win2003?) still uses it's

original
version.

Do you change the "culture" somewhere in your application?

Try this:
dt.ToString("dd/MM/yyyy hh:mm tt",

DateTimeFormatInfo.InvariantInfo);

Hans Kesting


Nov 18 '05 #9
Could be. I was surprised when my code didn't produce the expected result on
your system!

"Razak" <ra***@mmsc.com.my> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl...
It's Date taken: Malay (Malaysia):English (United States)

I remember setting my server to Malay(Malaysia) before, but have changed
it
to English(UK).
Could that be the problem? Perhaps Malay culture setting has no AM/PM
Designators set.


Nov 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: suzy | last post by:
i am having problems after problems... first i tried to create a page template and finally got that to work. so currently all my pages inherit from a template page class. i am adding controls...
10
by: Mr Newbie | last post by:
DropDown lists and Listboxes do not appear in the list of controls and values passed back to the server on PostBack in Request.Form object. Can someone confirm this to be correct and possibly...
17
by: B. Chernick | last post by:
I'm trying to create a web page and I need a javascript function to be called on the load of a particular panel. (The panel is hidden during some but not all postbacks.) The function is bound...
12
by: -Lost | last post by:
Sorry, for two separate browser questions, but I figured a multi-post about the same URL might not get favorable results. I am making a little website for the daycare my mother and wife works at...
8
by: Randy Smith | last post by:
Hi, I now need to add MasterPages to a number of existing forms, but when I add the code for MasterPage, the MasterPage does NOT appear when it runs. Any thoughts? TIA, Randy Smith
1
by: Dave | last post by:
When a user logs into my site, a row for order info is inserted into an MDB table. The next page uses a databound control that references the quantity in that newly created row. Is it possible...
10
by: paulie | last post by:
Hi, I have been experiencing an issue when trying to use AJAX to reload a DIV area using a timer of 2000ms, which contains a html page with another DIV and javascript. Scenario -------------...
5
by: Lawrence Krubner | last post by:
Please use FireFox to check out this page: http://www.cyberbitten.com/ Do you see the text near the top that reads "Be a part of the movement!" ? Okay, now go look at the same page in IE 7...
0
by: David Kempler | last post by:
Hi I am new in Visual Basic.Net. I am trying to develop my first site in VB 2008. I downloaded a demo source and changing it to my needs. I am trying now to add a new page: I wrote the ASP file...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.