help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question on datestr()


From: Nicholas Jankowski
Subject: Re: Question on datestr()
Date: Mon, 25 Jan 2016 07:34:55 -0500

On Mon, Jan 25, 2016 at 3:55 AM, address@hidden <address@hidden> wrote:
>
> Dear listmembers,
> trying to use "datestr" gives me unexpected results with hour / minute / second - information. I am issueing
>
> datestr(date,31)
>
> and get
> ans = 2016-01-25 00:00:00
>
> I am issueing
>
> datestr(13)
>
> and get
> ans = 00:00:00
>
> In contrast my watch and "date" tell me
> Mo 25. Jan 09:53:34 CET 2016


date:
Return the current date as a character string in the form DD-MMM-YYYY.

so when you pass date to datestr, you're only passing it the calendar date, already as a string, and not any information for it to process a time of day.  format 31 then just displays zeros for time , as it should.

I'm not sure what you expect to get from datestr(13).  I would expect something like "Jan 13, 0000". pretty sure when datestr is given a number it assumes its a serial day number like the output from datenum

if you want the current time/date, try datestr(now), or check out the other functions described here:
https://www.gnu.org/software/octave/doc/interpreter/Timing-Utilities.html#XREFnow

nickj

reply via email to

[Prev in Thread] Current Thread [Next in Thread]