0

I have a string coming in from the database say, ExpectedDate. I get the string in as 2015-07-08T00:00:00. I want to be able to remove the T00:00:00.from the string. Is this possible in MVC from the homecontroller javascript? if so, how?

I've tried to use a replace function, but I can't find the replace method in the MVC javascript file. What am I doing wrong?

Please help!

1
  • What is meaning of MVC javascript file? is it .js file or .cshtml ? Commented Mar 3, 2016 at 11:48

1 Answer 1

0

Controllers are not generally written in JavaScript in .NET. If you're going to do it in JavaScript client side, it would be much easier to load it into a Date object and then use the toDateString method with a format:

var d = new Date("2015-07-08T00:00:00")
d.toDateString("yyyy-MM-dd");

If you have the .NET DateTime object before it writes to the client, then you can do

your_date_time_object.ToString("yyyy-MM-dd");
Sign up to request clarification or add additional context in comments.

2 Comments

I'm trying to do something like this stackoverflow.com/questions/28326921/… - but instead of reading from the front of the string, I obviously want to remove from the end of string
The example you're referencing uses AngularJs. Are you using Angular or just MVC?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.