[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to change the date format in asp.net

Posted on 2009-06-29
2
Medium Priority
?
1,736 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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.
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

656 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