Using current time in UTC as default value in PostgreSQL

I have a column of the TIMESTAMP WITHOUT TIME ZONE type and would like to have that default to the current time in UTC. Getting the current time in UTC is easy: postgres=# select now() at time zone ‘utc’; timezone —————————- 2013-05-17 12:52:51.337466 (1 row) As is using the current timestamp for a column: postgres=# … Read more

How to get time difference between publish date and now?

I want to get time difference like “posted 2 days ago”. I know you can use the following to get the difference. human_time_diff( get_the_time(‘U’), current_time( ‘timestamp’ ) ) . ‘ ago’; But I don’t want to use that date_default_timezone_set(‘Australia/Melbourne’); // set the time zone $timestamp = strtotime( $post->post_date ); // get timestamp $now = time();// … Read more

How to convert integer timestamp to Python datetime

I have a data file containing timestamps like “1331856000000”. Unfortunately, I don’t have a lot of documentation for the format, so I’m not sure how the timestamp is formatted. I’ve tried Python’s standard datetime.fromordinal() and datetime.fromtimestamp() and a few others, but nothing matches. I’m pretty sure that particular number corresponds to the current date (e.g. … Read more

Convert datetime to Unix timestamp and convert it back in python

I have dt = datetime(2013,9,1,11), and I would like to get a Unix timestamp of this datetime object. When I do (dt – datetime(1970,1,1)).total_seconds() I got the timestamp 1378033200. When converting it back using datetime.fromtimestamp I got datetime.datetime(2013, 9, 1, 6, 0). The hour doesn’t match. What did I miss here? 12 Answers 12

Display date only once for a each set of posts relating to that date

The following loop works great for me in getting posts with a given date with the use of the_time(…): <?php $myPost = new WP_Query( array( ‘posts_per_page’ => ’50’, ‘orderby’ => ‘modified’, ‘order’ => ‘DESC’ )); while ($myPost->have_posts()): $myPost->the_post(); ?> <div class=”timeline-group”> <p class=”modified-time”><?php the_time(‘F j, Y’) ?></p> <h5><a href=”https://wordpress.stackexchange.com/questions/274206/<?php the_permalink();?>”><?php the_title();?></a></h5> </div> <?php endwhile; //Reset … Read more