DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 7 Aug 2007 10:14:43 +0100,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Smuggy
          2    SevDer am
                 3    Smuggy
                        4    Mark Rae [MVP]
                        5    Smuggy
          6    Alexey Smirnov
          7    Alexey Smirnov
          8    Alexey Smirnov
          9    Alexey Smirnov


How to get DateTime in required format?   
Hello group
I am using the now function to obtain the time, however because
my server is located in a different locale, I am getting the wrong
format - instead of 07/08 etc I am getting 08/07 etc (the American
format). Is there a simple way to change this?
Date:Tue, 7 Aug 2007 10:14:43 +0100   Author:  

Re: How to get DateTime in required format?   
Hi,

Use DateTime.ParseExact("parsing string", iformatprovider) where in format 
provider you can specify the culture.
I hope that will be a good start point.

SevDer
www.sevder.com

<Smuggy> wrote in message news:ekZcqNN2HHA.5740@TK2MSFTNGP04.phx.gbl...

> Hello group
> I am using the now function to obtain the time, however because
> my server is located in a different locale, I am getting the wrong
> format - instead of 07/08 etc I am getting 08/07 etc (the American
> format). Is there a simple way to change this?
>
> 
Date:Tue, 7 Aug 2007 05:23:22 -0400   Author:  

Re: How to get DateTime in required format?   
On Aug 7, 11:14 am, <Smuggy> wrote:

> Hello group
> I am using the now function to obtain the time, however because
> my server is located in a different locale, I am getting the wrong
> format - instead of 07/08 etc I am getting 08/07 etc (the American
> format). Is there a simple way to change this?


to format output you can use the ToString() method with appropriate
formats as follows

DateTime.Today.ToString("dd/MM");
Date:Tue, 07 Aug 2007 02:23:37 -0700   Author:  

Re: How to get DateTime in required format?   

> Use DateTime.ParseExact("parsing string", iformatprovider) where in format
> provider you can specify the culture.
> I hope that will be a good start point.


I have

dim a as datetime
a.parseexact(a.today,"en-GB")

is this correct?


>
> SevDer
> www.sevder.com
Date:Tue, 7 Aug 2007 10:37:08 +0100   Author:  

Re: How to get DateTime in required format?   
On Aug 7, 11:23 am, "SevDer" <sev...@newsgroup.nospam> wrote:

> Hi,
>
> Use DateTime.ParseExact("parsing string", iformatprovider) where in format
> provider you can specify the culture.
> I hope that will be a good start point.
>


He is using the Now function to obtain the time



> > I am using the now function to obtain the time
Date:Tue, 07 Aug 2007 02:39:24 -0700   Author:  

Re: How to get DateTime in required format?   
<Smuggy> wrote in message news:ucMlNaN2HHA.4712@TK2MSFTNGP04.phx.gbl...


>> Use DateTime.ParseExact("parsing string", iformatprovider) where in 
>> format
>> provider you can specify the culture.
>> I hope that will be a good start point.
>
> I have
>
> dim a as datetime
> a.parseexact(a.today,"en-GB")
>
> is this correct?


DateTime.Now.ToString("dd MMM yyyy"), assuming you want both Y2k 
compatability and non-ambiguity...


-- 
Mark Rae
ASP.NET MVP
http://www.markrae.net
Date:Tue, 7 Aug 2007 10:43:49 +0100   Author:  

Re: How to get DateTime in required format?   
On Aug 7, 11:37 am, <Smuggy> wrote:

> > Use DateTime.ParseExact("parsing string", iformatprovider) where in format
> > provider you can specify the culture.
> > I hope that will be a good start point.
>
> I have
>
> dim a as datetime
> a.parseexact(a.today,"en-GB")
>
> is this correct?
>


DateTime.ParseExact method converts the string to a date. You have
already a date value. All what you need is to show that date in the
format you need. Either use .ToString() method, or change a culture in
your application.

Go to web.config and add this

<globalization culture="en-GB" uiCulture="en-GB" />
Date:Tue, 07 Aug 2007 02:45:07 -0700   Author:  

Re: How to get DateTime in required format?   

> Go to web.config and add this
>
> <globalization culture="en-GB" uiCulture="en-GB" />


Thanks, I did it this way, I found it in the msdn

System.Threading.Thread.CurrentThread.CurrentCulture = New
System.Globalization.CultureInfo("en-GB", False)

After this the Now function works correctly.



>
Date:Tue, 7 Aug 2007 11:06:17 +0100   Author:  

Re: How to get DateTime in required format?   
On Aug 7, 12:06 pm, <Smuggy> wrote:

> > Go to web.config and add this
>
> > <globalization culture="en-GB" uiCulture="en-GB" />
>
> Thanks, I did it this way, I found it in the msdn
>
> System.Threading.Thread.CurrentThread.CurrentCulture = New
> System.Globalization.CultureInfo("en-GB", False)
>
> After this the Now function works correctly.


It will work, but you always have to set the culture for the current
thread. If your application is designed for UK only, you can specify
that value on the global level in the web.config file. You also can
use the @Page Directive

<%@Page Culture="en-GB" ....

Hope this helps
Date:Tue, 07 Aug 2007 03:23:34 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us