Script simples para vizualização de formato de data e hora.
====== usando C#
<script language ="c#" runat = "server">
void Page_Load(Object src, EventArgs e) {
DateTime myDate = DateTime.Now;
normal.Text = myDate.ToString();
shortdt.Text = myDate.ToShortDateString();
longdt.Text = myDate.ToLongDateString();
longtm.Text = myDate.ToLongTimeString();
shorttm.Text = myDate.ToShortTimeString();
}
</script>
<p>Normal : <asp:label id = "normal" runat = "server" /></p>
<p>Data Curta : <asp:label id = "shortdt" runat = "server" /></p>
<p>Data Longa : <asp:label id = "longdt" runat = "server" /></p>
<p>Hora Longa : <asp:label id = "longtm" runat = "server" /></p>
<p>Hora Curta : <asp:label id = "shorttm" runat = "server" /></p>
====== usando VB
<script language ="vb" runat = "server">
Sub Page_Load(src as object , e as eventargs)
dim myDate = DateTime.Now
normal.Text = myDate.ToString()
shortdt.Text = myDate.ToShortDateString()
longdt.Text = myDate.ToLongDateString()
longtm.Text = myDate.ToLongTimeString()
shorttm.Text = myDate.ToShortTimeString()
end Sub
</script>
<p>Normal : <asp:label id = "normal" runat = "server" /></p>
<p>Data Curta : <asp:label id = "shortdt" runat = "server" /></p>
<p>Data Longa : <asp:label id = "longdt" runat = "server" /></p>
<p>Hora Longa : <asp:label id = "longtm" runat = "server" /></p>
<p>Hora Curta : <asp:label id = "shorttm" runat = "server" /></p>
exemplo: http://www.fixe.com.br/asp4d/data.aspx
download do código: http://www.fixe.com.br/asp4d/data.zip
0 comentários:
Postar um comentário