Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function [str] = timestrForFile( num )
% generate a timestamp for file
% this time stamp has eliminated charactors forbidden in filename
% num is a num for time stamp, now is the default.
if nargin==0
num = now;
timestr = datestr(num);
timestr= regexprep (timestr,':','-');
str = regexprep (timestr,'\s','-');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment