Inserting current date in string

7 visualizzazioni (ultimi 30 giorni)
Syed Abbas
Syed Abbas il 17 Gen 2012
Hi,
I have a string such as follows:
st = 'Today is January 17 2012'
How can I automatically insert today's date in this string without manually typing it into the string. I am looking for something of the form:
st = 'Today is datestr(now)' - but obviously this does not produce the desired result.
Thanks,

Risposta accettata

bym
bym il 17 Gen 2012
sprintf('today is %s',datestr(now()))

Più risposte (1)

Thomas
Thomas il 17 Gen 2012
Use:
str=['Today is ',date]

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by