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

I am using fromNow and when I validate my html I get a error #130

Open
mabdulul opened this issue Jan 18, 2021 · 1 comment
Open

I am using fromNow and when I validate my html I get a error #130

mabdulul opened this issue Jan 18, 2021 · 1 comment

Comments

@mabdulul
Copy link

mabdulul commented Jan 18, 2021

The error is Bad value 1610828671000 for attribute datetime on element time: Year out of range
This is the output <time datetime="1610828671000">1d ago</time>
<Moment fromNow>{job.created_at}</Moment>

@headzoo
Copy link
Owner

headzoo commented Jan 19, 2021

Try something like this. Note the unix attribute and I'm dividing your number by 1000 because it appears to be microseconds (typically returned by javascript's Date class) while timestamps need to be seconds.

export default class MyComponent extends React.Component {
    render() {
        const unixTimestamp = 1610828671000 / 1000;
        return (
            <Moment unix fromNow>
                {unixTimestamp}
            </Moment>
        );
    }
}

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

2 participants