Is there a toString function in K#?

Yang Wen asked on February 11, 2016 21:53

This code works fine {% TrimStart("2016",2) %} for returning "16"

However this doesn't work {% TrimStart(DateTime.CurrentDateTime.Year,2)%}

Even though there is no mention in the document, I assume .Year is returning a non string type, which causes TrimStart to fail.

How do I convert the return value of DateTime.CurrentDateTime.Year to string? Or how do I return a custom formatted year value from CurrentDateTime.Year such that I get "16" instead of "2016" ?

This seems like a very basic server-side thing to do.. Can't figure out how to do it with K#. Thanks

Correct Answer

Joshua Adams answered on February 11, 2016 22:26

Check this out: Search for the ToString method. You may have to play around with the usage, I have done it before, and remember it being difficult to figure out.

0 votesVote for this answer Unmark Correct answer

Recent Answers

Yang Wen answered on February 11, 2016 22:33

argh! i see the toString method there! Don't know how I missed it before, i've been searching all over.. I'll try it out!

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on February 12, 2016 04:44

Could you please mark an answer appropriately if it was useful for you? Thanks! :)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.