From: jay jay on
Hi,

I want to convert a date into 'seconds from epoch(00:00:00 1 January 1970)'

for example,
if date = 2007/06/20
seconds from epoch = 1182312000

Here i consider by default the time of the desired date as 00:00:00 of 2007/06/20.

Thanks in advance.
From: jay jay on
"jay jay" <jay.oberoi(a)yahoo.com> wrote in message <i0812k$can$1(a)fred.mathworks.com>...
> Hi,
>
> I want to convert a date into 'seconds from epoch(00:00:00 1 January 1970)'
>
> for example,
> if date = 2007/06/20
> seconds from epoch = 1182312000
>
> Here i consider by default the time of the desired date as 00:00:00 of 2007/06/20.
>
> Thanks in advance.

E=[1970 01 01 00 00 00]
D1=[2007 06 20 00 00 00]
secsFromEpoch = int32((datenum(D1)-datenum(E))*86400)

this gives me
secsFromEpoch = 1182297600

This is off by 4 hours(3600*4=14400 secs) from the actual value of 1182312000.

Can someone help me. I dont understand what's the mistake i am making.
From: us on
"jay jay" <jay.oberoi(a)yahoo.com> wrote in message <i086d5$l5s$1(a)fred.mathworks.com>...
> "jay jay" <jay.oberoi(a)yahoo.com> wrote in message <i0812k$can$1(a)fred.mathworks.com>...
> > Hi,
> >
> > I want to convert a date into 'seconds from epoch(00:00:00 1 January 1970)'
> >
> > for example,
> > if date = 2007/06/20
> > seconds from epoch = 1182312000
> >
> > Here i consider by default the time of the desired date as 00:00:00 of 2007/06/20.
> >
> > Thanks in advance.
>
> E=[1970 01 01 00 00 00]
> D1=[2007 06 20 00 00 00]
> secsFromEpoch = int32((datenum(D1)-datenum(E))*86400)
>
> this gives me
> secsFromEpoch = 1182297600
>
> This is off by 4 hours(3600*4=14400 secs) from the actual value of 1182312000.
>
> Can someone help me. I dont understand what's the mistake i am making.

two thoughts
most likely,
- ML's result is correct...
- you forgot to add/subtract a time-zone correction in your original result...

us
From: jay jay on
"us " <us(a)neurol.unizh.ch> wrote in message <i087et$s2q$1(a)fred.mathworks.com>...
> "jay jay" <jay.oberoi(a)yahoo.com> wrote in message <i086d5$l5s$1(a)fred.mathworks.com>...
> > "jay jay" <jay.oberoi(a)yahoo.com> wrote in message <i0812k$can$1(a)fred.mathworks.com>...
> > > Hi,
> > >
> > > I want to convert a date into 'seconds from epoch(00:00:00 1 January 1970)'
> > >
> > > for example,
> > > if date = 2007/06/20
> > > seconds from epoch = 1182312000
> > >
> > > Here i consider by default the time of the desired date as 00:00:00 of 2007/06/20.
> > >
> > > Thanks in advance.
> >
> > E=[1970 01 01 00 00 00]
> > D1=[2007 06 20 00 00 00]
> > secsFromEpoch = int32((datenum(D1)-datenum(E))*86400)
> >
> > this gives me
> > secsFromEpoch = 1182297600
> >
> > This is off by 4 hours(3600*4=14400 secs) from the actual value of 1182312000.
> >
> > Can someone help me. I dont understand what's the mistake i am making.
>
> two thoughts
> most likely,
> - ML's result is correct...
> - you forgot to add/subtract a time-zone correction in your original result...
>
> us

Thanks. I'll check that.
 | 
Pages: 1
Prev: hiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
Next: Code request