Effacer les filtres
Effacer les filtres

Inserting current date in string

5 vues (au cours des 30 derniers jours)
Syed Abbas
Syed Abbas le 17 Jan 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,

Réponse acceptée

bym
bym le 17 Jan 2012
sprintf('today is %s',datestr(now()))
  1 commentaire
Syed Abbas
Syed Abbas le 17 Jan 2012
Thanks!

Connectez-vous pour commenter.

Plus de réponses (1)

Thomas
Thomas le 17 Jan 2012
Use:
str=['Today is ',date]
  1 commentaire
Syed Abbas
Syed Abbas le 17 Jan 2012
Thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by