How do you write a program that gives the current time and day?

1 次查看(过去 30 天)
I am very new to programming, and cannot figure out how to run this program correctly. My work is shown below. Please Help!
time = clock ();
day = date ();
fprintf('The current date is %f\n', day);
fprintf('The current time is %0f\n', time);

采纳的回答

KSSV
KSSV 2021-2-8
d = datetime('now') ;
fprintf('The current date is %s\n', d);
The current date is 08-Feb-2021 05:19:58

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by