Solved

How to change the date format in asp.net

Posted on 2009-06-29
2
1,724 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

749 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