Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMike Hansen
Python Web Development Techdegree Student 3,419 PointsIn social web app in python it says 46 years ago in posted_ago
hi, i noticed that in the post you make it says posted 46 years ago instead of 5 seconds, 2 minutes etc. How do i change that?
2 Answers
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 PointsHi, this bugged me too, so looked deeper into it.
The problem is that disTime.js that converts the datetime to strings like " 5 days ago " requires a UNIX-Timestamp. The following change worked for me.
<i class="clock"></i>
<time data-time="{{ post.timestamp.timestamp() }}" class="distime" datetime="{{ post.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}">{{ post.timestamp.timestamp() }}</time>
<a href="{{ url_for('view_post', post_id=post.id) }}" class="view">View</a>
Aya Yousef
9,658 PointsThanks for sharing that, but for this change alone, you'll get this error:
UndefinedError: 'datetime.datetime object' has no attribute 'timestamp'
There should be something else that needs to be modified.