1
votes

Hello everyone im trying to rewrite a matlab code into python and im having troubles with datenum function (MATLAB). I couldnt find any similar function in python (in the way i need)

MATLAB code

t = datenum(EQdata{1},'yyyymmdd');

Where EQdata{1} is time and has this form 'yyyymmdd'

   '20000616'
   '20000512'
   '20000423'
   '20000423'
   '20000108'

And t

736978
737074
737081
737152
737160
737296

I found some function that might work, like this:

print date.toordinal(date(1970,1,1))

719163 

But my main problem is that i have time in 'yyyymmdd' format, and that function need month and day as a independent argument.

1

1 Answers

0
votes

You can use strptime():

datetime.strptime(eqdata[1], '%Y%m%d')