Date Formatting

Discussion in 'ASP.NET / ASP.NET Core' started by annbransom, Aug 16, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi, I am trying to cut off the time from a couple of dates on my website (they are in GMT and I need them in EST, but can't figure out how to change it). I have the format string set to short date but it is still displaying with the full timestamp. My code is below. The date in question is "LastPostDate". Let me know what I'm doing wrong:




    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Discussion.aspx.vb" Inherits="Discussion" title="Group Discussions" debug=true%>


    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


    <table align="center" cellpadding="10" width="760">


    <tr>


    <td>


    <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="12pt" Text="Label" Font-Names="Arial" ForeColor="Green"></asp:Label></td>


    </tr>


    <tr>


    <td>


    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ThreadID" AllowPaging="True" BorderColor="Green" BorderWidth="1px" GridLines="Horizontal" HorizontalAlign="Center" Width="700px">


    <Columns>


    <asp:ButtonField CommandName="Select" HeaderText="Subject" ShowHeader="True" Text="View Messages" DataTextField="Subject" />


    <asp:BoundField DataField="Username" HeaderText="Author" />


    <asp:BoundField DataField="Replies" HeaderText="Replies" />


    <asp:BoundField DataField="LastPostDate" HeaderText="Original Post" ApplyFormatInEditMode="True" DataFormatString="{0:d}" />


    </Columns>


    <PagerSettings Mode="NumericFirstLast" />


    <HeaderStyle BackColor="#F10380" Font-Bold="True" Font-Names="Arial" Font-Size="12pt" ForeColor="White" HorizontalAlign="Left" VerticalAlign="Top" />


    <AlternatingRowStyle BackColor="Honeydew" />


    </asp:GridView>


    </td>


    </tr>


    <tr>


    <td>


    <table align="center" width="700">


    <tr>


    <td>


    <table style="border-right: Green 1px solid; border-top: Green 1px solid; border-left: Green 1px solid; border-bottom: Green 1px solid" width="300">


    <tr>


    <td style="font-weight: bold; font-size: 12pt; width: 400px; color: white; font-family: Arial; background-color: #f10380">


    Start a new thread</td>


    </tr>


    <tr>


    <td style="width: 400px; height: 39px">


    Subject:&amp;nbsp;


    <asp:TextBox ID="TextBox1" runat="server" Width="327px" MaxLength="190"></asp:TextBox></td>


    </tr>


    <tr>


    <td align="center" style="width: 400px">


    <asp:Button ID="Button1" runat="server" Text="Start Thread" /></td>


    </tr>


    </table>


    </td>


    </tr>


    </table>


    </td>


    </tr>


    </table>








    &amp;nbsp;








    </asp:Content>


    <asp:Content ID="Content2" runat="server" ContentPlaceHolderID="ContentPlaceHolder2">


    <asp:Label ID="lblGroupName" runat="server" Text="Label" ForeColor="White"></asp:Label>


    <asp:Label ID="Label4" runat="server" Font-Size="12pt" Text="Label"></asp:Label></asp:Content>


    <asp:Content ID="Content3" runat="server" ContentPlaceHolderID="ContentPlaceHolder3">


    <asp:Menu ID="Menu2" runat="server" DynamicHorizontalOffset="10" Font-Bold="True" Font-Names="Arial" Font-Size="12pt" ForeColor="White" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False" StaticTopSeparatorImageUrl="~/Images/popoutimage.gif" Visible="False">


    <DynamicHoverStyle ForeColor="Lime" />


    <DynamicMenuStyle BackColor="#F10380" Height="50px" HorizontalPadding="3px" VerticalPadding="3px" />


    <DynamicMenuItemStyle Font-Size="10pt" />


    <Items>


    <asp:MenuItem NavigateUrl="~/groupadmin.aspx" Text="Admin" Value="Logout"></asp:MenuItem>


    </Items>


    <StaticHoverStyle ForeColor="Lime" />


    </asp:Menu>


    </asp:Content>
     
  2. Set HtmlEncode="false" i.e




    <asp:BoundField DataField="LastPostDate" HeaderText="Original Post" HtmlEncode="false" ApplyFormatInEditMode="true" DataFormatString="{0:d}" />


    Hope This Helps!!







    Vikram

    DiscountASP.NET
    www.DiscountASP.NET

    Post Edited (vvsharma) : 8/16/2006 9:33:37 PM GMT
     
  3. Setting HTMLEncode to False did the trick! Thanks!
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page