Take one label and one button (by default label will display the current date
if we click on the button it will show us format(mm/dd/yyyy)
string strdate = "";
string startdate = "";
SPWeb spWeb = new SPSite(SPContext.Current.Web.Url.ToString()).OpenWeb();
startdate = System.DateTime.Now.ToString();
Label1.Text = startdate;(To display current date)
//method to change date format dd/mm/yyyy to mm/dd/yyyy
public void GetDates(string date, out string Date)
{
Date = "";
string strYear = "";
string strMonth = "";
string strDay = "";
string[] Dates;
Dates = date.Split('/');
for (int i = 3; i <= Dates.Length; i--)
{
if (i > 0)
{
if (i == 2)
{
if (Dates.GetValue(i - 1).ToString().Length == 2)
{
strMonth = Dates.GetValue(i - 1).ToString();
}
else
{
strMonth = "0" + Dates.GetValue(i - 1).ToString();
}
}
if (i == 3)
{
strYear = Dates.GetValue(i - 1).ToString();
}
if (i == 1)
{
if (Dates.GetValue(i - 1).ToString().Length == 2)
{
strDay = Dates.GetValue(i - 1).ToString();
}
else
{
strDay = "0" + Dates.GetValue(i - 1).ToString();
}
}
}
if (i == 0)
{
Date = strMonth + "/" + strDay + "/" + strYear;
return;
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
// SPWeb spWeb = new SPSite("http://jagadeeshv:2222").OpenWeb();
if (spWeb.RegionalSettings.LocaleId != 1033)
{
GetDates(startdate, out strdate);
startdate = strdate;
Label1.Text = strdate;
}
else
{
Label1.Text = startdate;
}
}
Subscribe to:
Post Comments (Atom)
Content Editor Webpart not showing up in SharePoint Online ------------------------------------------------------------------------------...
-
Category : Admin Backup : For site collection backup : stsadm.exe -o backup -url -filename [-overwrite] For catastrophic backup: sts...
-
Regarding “SharePoint Foundation” and “SharePoint Server 2010”, the important thing to understand is that SharePoint Foundation is the found...
-
http://weblogs.asp.net/jan/archive/2010/05/07/sharepoint-2010-bdc-model-deployment-issue-the-default-web-application-could-not-be-determined...
No comments:
Post a Comment