1

In python I can do following

print "%02d:%02d" % (9, 6) # will output 09:06

How can I do this in TypeScript?

2 Answers 2

2

Use the sprintf-js library and types.

Sign up to request clarification or add additional context in comments.

1 Comment

This is actually very simple and elegant solution.
0

FIDDLE: https://jsfiddle.net/1ytxfcwx/

NPM: https://www.npmjs.com/package/typescript-string-operations

GITHUB: https://github.com/sevensc/typescript-string-operations

Either use Template Strings -> https://basarat.gitbooks.io/typescript/content/docs/template-strings.html

or you can use a class a wrote -> String.Format not work in TypeScript

or use my NPM package!

https://www.npmjs.com/package/typescript-string-operations

var value = String.Format("{0:L}", "APPLE"); //output "apple"

Comments

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.