How to change date formate dd/mm/yyyy

This forum is for questions and issues arising from the use of AbleCommerce 7.0 outside the United States. International purchases of AbleCommerce 7.0 are way up. Thank you!
Post Reply
ncm
Ensign (ENS)
Ensign (ENS)
Posts: 1
Joined: Mon Sep 15, 2008 7:22 pm

How to change date formate dd/mm/yyyy

Post by ncm » Mon Sep 15, 2008 7:45 pm

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

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

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

Post by mazhar » Fri Sep 19, 2008 4:26 am

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"

softpac
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 33
Joined: Mon Oct 22, 2007 12:08 am
Location: Australia

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

Post by softpac » Mon Apr 13, 2009 5:02 pm

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?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

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

Post by mazhar » Tue Apr 14, 2009 1:04 pm

Try

Code: Select all

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

softpac
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 33
Joined: Mon Oct 22, 2007 12:08 am
Location: Australia

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

Post by softpac » Tue Apr 14, 2009 4:04 pm

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

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

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

Post by mazhar » Mon Apr 19, 2010 11:55 am

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>

Post Reply