Java: Date from unix timestamp

I need to convert a unix timestamp to a date object. I tried this: java.util.Date time = new java.util.Date(timeStamp); Timestamp value is: 1280512800 The Date should be “2010/07/30 – 22:30:00” (as I get it by PHP) but instead I get Thu Jan 15 23:11:56 IRST 1970. How should it be done? 10 Answers 10

Is it safe to use ‘date_default_timezone_set’ in plugin file?

I am using a sitemaps plugin which in very complex ways sets the timezone of <lastmod> (i.e. last modified time) for posts to GMT. Temporarily, until the plugin developer fixes it, I need to enforce a custom timezone on the plugin. The simple and straightforward way that I’ve found is to add something like date_default_timezone_set( … Read more

Creation timestamp and last update timestamp with Hibernate and MySQL

For a certain Hibernate entity we have a requirement to store its creation time and the last time it was updated. How would you design this? What data types would you use in the database (assuming MySQL, possibly in a different timezone that the JVM)? Will the data types be timezone-aware? What data types would … Read more

Converting Unix timestamp to wordpress date

I have trouble converting Unix timestamp (i.e. 1473897600) to WordPress friendly date which displays at the date input field. I have a frontpage, post edit panel which is showing Unix timestamp. I guess this is the code for getting the post’s date; <?php $post_to_edit = array(); $post_to_edit = get_post($_POST[‘postid’]); $date = $_POST[ ‘_single_date’ ]; ?> … Read more