Solved

How to change the date format in asp.net

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now