Page 1 of 1

How to change date formate dd/mm/yyyy

Posted: Mon Sep 15, 2008 7:45 pm
by ncm
Hi

After doing some searching on the forum and looking at the control panel options I can't see a way to change the date format to day / month / year, is this something that requires a code change or is there an admin option for it?


Cheers

Re: How to change date formate dd/mm/yyyy

Posted: Fri Sep 19, 2008 4:26 am
by mazhar
You have to change the code. But it will be a very simple change. You just need to call the ToString() function on the date object with some suitable parameter. For example in your case it could be

Code: Select all

theDate.ToString("d");       // result = "03/01/2007"

Re: How to change date formate dd/mm/yyyy

Posted: Mon Apr 13, 2009 5:02 pm
by softpac
Unfortunately, I cannot see how your suggestion works in the following instance:

~/Admin/Orders/Print/Invoices.aspx

There is a line for Order Date:

<asp:Label ID="OrderDate" runat="server" Text='<%# Eval("OrderDate", "{0:g}") %>'></asp:Label>

How do we change the default US date format to Australian date format (dd/mm/yyyy) in the above instance?

Re: How to change date formate dd/mm/yyyy

Posted: Tue Apr 14, 2009 1:04 pm
by mazhar
Try

Code: Select all

<asp:Label ID="OrderDate" runat="server" Text='<%# Eval("OrderDate", "{0:g}").ToString("d") %>'></asp:Label>

Re: How to change date formate dd/mm/yyyy

Posted: Tue Apr 14, 2009 4:04 pm
by softpac
Thanks Mazhar for the code snippet. I tried it, but I get the following error:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1502: The best overloaded method match for 'string.ToString(System.IFormatProvider)' has some invalid arguments

Source Error:

Line 190: <asp:Label ID="OrderNumber" runat="server" Text='<%# Eval("OrderNumber") %>'></asp:Label><br />
Line 191: <asp:Label ID="OrderDateLabel" runat="server" Text="Order Date:" SkinID="FieldHeader"></asp:Label>
Line 192: <asp:Label ID="OrderDate" runat="server" Text='<%# Eval("OrderDate", "{0:g}").ToString("d") %>'></asp:Label><br />
Line 193: </div>
Line 194: </td>


Source File: c:\inetpub\vhosts\boots-n-all.com.au\httpdocs\Admin\Orders\Print\Invoices.aspx Line: 192

Re: How to change date formate dd/mm/yyyy

Posted: Mon Apr 19, 2010 11:55 am
by mazhar
In Order Manager update the Order Date Label as below

Code: Select all

<asp:Label ID="Label6" runat="server" Text='<%# Eval("OrderDate", "{0:dd/MM/yyyy}") %>'></asp:Label>