Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse return wrong date #40

Open
ehudg opened this issue Nov 25, 2020 · 2 comments
Open

parse return wrong date #40

ehudg opened this issue Nov 25, 2020 · 2 comments

Comments

@ehudg
Copy link

ehudg commented Nov 25, 2020

Hi, I'm using the following code:

       `var originImage = await s3.getObject(params).promise();       
      
        var buffer = await sharp(originImage.Body).withMetadata().toBuffer(); 
                    
        var parser = require('exif-parser').create(buffer);

        var exifData = await  metaDataService.Convert(parser.parse());`

All the data is fine, expect for the dates. I'm getting the following:

ModifyDate: 1595773338,
DateTimeOriginal: 1595168559,
CreateDate: 1595168559,

All these and translated to dates from 1970 (!).

But the image creation date is 19/07/2020 14:22.

What might be the problem?

Thanks

@goranbasso
Copy link

goranbasso commented Jan 12, 2021

They seem to be without the millisecond part, so you need to multiply it by 1000 to get the correct date:

> new Date(1595168559)
> Mon Jan 19 1970 11:06:08

> new Date(1595168559 * 1000)
> Sun Jul 19 2020 14:22:39

If you need the milliseconds part, they can be found in the SubsecTimeOriginal (and similar) EXIF-fields.

@wizi-sky
Copy link

It’s not that there are no seconds. The time obtained here is the date and time in the form of Unix timestamp. If you need to obtain the normal time, you need to multiply it by 1000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants