Skip to content

Instantly share code, notes, and snippets.

@sandyUni
Created December 13, 2016 12:25
Show Gist options
  • Save sandyUni/257e04a6bdfdf5844d7b5726e48b290c to your computer and use it in GitHub Desktop.
Save sandyUni/257e04a6bdfdf5844d7b5726e48b290c to your computer and use it in GitHub Desktop.
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;
end
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