Jack Marchetti
Jack Marchetti

Reputation: 15754

(ASP.NET) How do I remove special characters when doing a DateTime.Now.ToString()

So I have a flashobject which I need to pass a formatted DateTime string to.

My code:

string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

which outputs as: 2009-09-16 22:26:45

However when it is actually output to HTML and swfobject it renders it as:

so.addVariable("inNowDate","2009-09-16+22%3a25%3a13");

I think this is messing up a calculation that the flash object does based off the current time. Do I need to encode or decode this?

Any help would be greatly appreciated! Thanks!

Upvotes: 0

Views: 1176

Answers (2)

Steve
Steve

Reputation: 5952

When you output to html, try using UrlDecode.

http://msdn.microsoft.com/en-us/library/6196h3wt.aspx

Upvotes: 0

Eric J.
Eric J.

Reputation: 150148

It's not that you have gained special characters, but rather certain special characters you already had are now URL encoded.

There's not enough information present for me to see exactly where this URL encoding his happening. Can you post a bit more context?

Upvotes: 1

Related Questions