Solved

How to change the date format in asp.net

Posted on 2009-06-29
2
1,729 Views
Last Modified: 2013-11-18
Hi,
I want to change date format of pubDate to dd-mm-yy.

Code is:
<body>
    <form id="form1" runat="server">
    <div>
        <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="http://blogs.msdn.com/amit_chatterjee/rss.xml"
            XPath="rss/channel/item [position()<=1]" CacheDuration="60"></asp:XmlDataSource>
    </div>
        <asp:DataList  Runat="server" DataSourceID="XmlDataSource1" >
            <ItemTemplate>
                <asp:Label ID="Label1" Runat="server" Text='<%# XPath("pubDate") %>' ForeColor="black" Font-Bold="True"></asp:Label>
            </ItemTemplate>
        </asp:DataList>
    </form>
</body>

The output of above code is Sat, 13 Jun 2009 04:38:00 GMT can you help me how to convert this to 04:38 hrs, 13-06-09 .

Thanks in advance
0
Comment
Question by:Byteridge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Expert Comment

by:PIERCGG
ID: 24738372
As explained on this web page, you could do this:
http://forums.asp.net/t/707491.aspx



<asp:FormView ID="fmviewAccDate" runat="server" DataSourceID="sqldsReviewDetail">
<ItemTemplate>
<asp: Label ID="lblModalAccomplishDate" runat="server" Text='<%# Bind("PTRT_Accomplish_Date", "{0:dd/MM/yyyy}") %>'>
</asp:Label>
</ItemTemplate>
</asp:FormView>
0
 
LVL 2

Accepted Solution

by:
Byteridge earned 0 total points
ID: 24791771
I found the solution is
<%# String.Format("{0:HHmm 'hrs,' dd-MM-yy}", Convert.ToDateTime(XPath("pubDate")))%>

Cheers
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question