Monday, December 24, 2007

How to pass DateTime Timestamp to Sharepoint 2007

Hi Folks,

if you developing sharepoint application,you will face that the DateTime timestamp parameter on sharepoint is different than what you are used to pass in your .Net Application.

In SharePoint 2007,the TimeStamp has to passed as a string and this is the format of the string:

"YYYYMMDDTHHMMDDZ"

Take these Notes:

1) Date Part is followed by T Symbol.
2) Time Part is followed by Z Symbol.

and the the rest of the string is easy to get it in your application by using:

C#:
DateTime.Now.Date.ToShortDateString()
DateTime.Now.Date.ToShortTimeString()

By using any string concatenation "+" or use String Builder Class to give better performance.


Hope this helps................


Regards,
Moustafa arafa

3 comments:

Anonymous said...

Thanks for posting this, it's exactly what I was looking for.

Cheers!

M@YO said...

Mostafa do you have an idea about how to solve this

When uploading or creating new document on SP2007 I have the Modified or Created time, 3 hours after the time I acually created in so if the server time is 12 PM I got that the creation time of the SP document is 3 PM

Thank You

Unknown said...

To fix this, go to your site settings and check the time zone you would like to have on your site.