This is a migrated thread and some comments may be shown as answers.

[Solved] Format DateTime with Current Culture

2 Answers 269 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Piero Casiraghi
Top achievements
Rank 1
Piero Casiraghi asked on 26 Feb 2010, 11:37 PM
I need to format DateTime values with the current culture.

So i can't write something like this:
columns
.Add(o => o.OrderDate).Format("{0:MM/dd/yyyy}")

I 've tried:
columns.Add(o => o.OrderDate.ToShortDateString())
but it display a string empty.

I've also tried:
columns.Add(o => o.OrderDate.ToString("d"))


Can you help me?
Thanks



2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 01 Mar 2010, 08:01 AM
Hello Piero Casiraghi,

If you are using server binding only the grid should support that if you provide any of the predefined date formats - e.g. "D", "G" etc. If you are using client-side binding (ajax or web service) make sure the Globalization method of the ScriptRegistrar is called:

<%= Html.Telerik().ScriptRegistrar().Globalization(true) %>


In both cases make sure the Culture of your View is set to the appropriate value which is required for proper globalization support provided by the .NET runtime.

I hope this helps,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
ori
Top achievements
Rank 1
answered on 12 Jan 2012, 05:35 PM
Hi,

This one works for me: columns.Bound(a => a.Modified).Format("{0:g}");


can we set the format as we can do for the datpicker:
 @(Html.Telerik().DatePicker().Format("dd/MM/yyyy") ?

this one doesnt work: columns.Bound(a => a.Modified).Format(""dd/MM/yyyy"");

i get in the grid "dd/MM/yyyy" and not the date.

Thank you

Ori
Tags
Grid
Asked by
Piero Casiraghi
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
ori
Top achievements
Rank 1
Share this question
or