Skip to content

Commit

Permalink
feat: update createdAt and updatedAt fields to store timestamps in UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
HemalDesai committed Sep 13, 2024
1 parent bca66e9 commit f9d77f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions app/utils/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ export function timeAgo(date: Date) {
const seconds = Math.floor((now.getTime() - date.getTime()) / 1000);

let interval = Math.floor(seconds / 31536000);
if (interval > 1) {
if (interval >= 1) {
return `${interval}y ago`;
}
interval = Math.floor(seconds / 2592000);
if (interval > 1) {
if (interval >= 1) {
return `${interval}mo ago`;
}
interval = Math.floor(seconds / 86400);
if (interval > 1) {
if (interval >= 1) {
return `${interval}d ago`;
}
interval = Math.floor(seconds / 3600);
if (interval > 1) {
if (interval >= 1) {
return `${interval}h ago`;
}
interval = Math.floor(seconds / 60);
if (interval > 1) {
if (interval >= 1) {
return `${interval}m ago`;
}
return `Just Now`;
Expand Down
4 changes: 2 additions & 2 deletions server/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export const jobPostingsTable = pgTable('job_postings', {
}),
isPublished: boolean('is_published').default(false).notNull(),
totalApplicants: integer('total_applicants').default(0).notNull(),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
});

export type JobPosting = typeof jobPostingsTable.$inferSelect;
Expand Down

0 comments on commit f9d77f3

Please sign in to comment.