Code covered by the BSD License  

Highlights from
current_date

1.0

1.0 | 2 ratings Rate this file 0 Downloads (last 30 days) File Size: 1.26 KB File ID: #25932

current_date

by SamGhim

 

23 Nov 2009

prints out current date and time.

| Watch this File

File Information
Description

nothing fancy, it just prints out current date and time. I wrote it just for fun :)

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
24 Nov 2009 Jan Simon

Rounding the seconds is not correct: 59.6 sec should not be displayed as 60! Better use FIX.
Instead of NUM2STR and adding a leading '0', you can call SPRINTF('%.2d', hr) to get 2 digits. This can be combined:
  full_date = clock;
  date = sprintf('%.4d/%.2d/%.2d', full_date(1:3));
  time = sprintf('%.2d:%.2d:%.2d', fix(full_date(4:6)));

Have you seen DATESTR?

25 Nov 2009 Jos (10584)

Do no rely on this when you have to be on time ...
>> [d,t] = current_date
% d = 2009\11\25
% t =10:11:54
>> datestr(now)
ans = 25-Nov-2009 10:49:07

This trivial submission might have only some educational value, but than it should 1) work correctly; 2) have a lot of (edcucational) comments; and 3) a superior help section

I would recommend anyone to use DATESTR.

17 Jan 2010 Jan Simon

Jos found a bug, which is caused by using "mn" as name of the variables for minutes and month. The bug has not been fixed for 8 weeks.
Although I appreciate that you write programs just for fun, the real fun for publishing functions in the FEX start, if the functions are working and if others can use them. Please update or remove this function.
Thanks.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
date SamGhim 24 Nov 2009 09:50:30
time SamGhim 24 Nov 2009 09:50:30
clock SamGhim 24 Nov 2009 09:50:30

Contact us at files@mathworks.com