Mike
Mike

Reputation: 3276

What format of a timestamp is this?

I have to make some changes on an wordpress plugin. The plugin gives back this timestamp format: 1364495828.1500 What's the name of this format and how can I change it to DD/MM/YYYY - HH:MM??? I am using PHP Thanks!

Upvotes: 2

Views: 582

Answers (3)

O. Jones
O. Jones

Reputation: 108676

This is a UNIX timestamp to a resolution of 100 microseconds.

Try this to get it into a DATETIME format in your SQL statement.

 FROM_UNIXTIME(1364495828.1500)

You can also give a second parameter to the function containing a DATE_FORMAT string, and get the date string you want. For example, this gets you a timestamp string like 16/06/2013 14:25

 FROM_UNIXTIME(1364495828.1500, '%d/%m/%Y - %H:%i')

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format

But, if you're working in WordPress, you may prefer to do this in PHP. If you use PHP code like this you'll use the WordPress date format and time format settings chosen by the user, and get the the kind of result your user expects.

  $timestring = date_i18n( get_option( 'date_format' ), '1364495828.1500' ) . 
                ' ' .
        date_i18n( get_option( 'time_format' ), '1364495828.1500' );

These are chosen on the general settings page in WordPress's administrative interface.

Upvotes: 4

Marc B
Marc B

Reputation: 360692

It's just the result of:

$ts = microtime(true); // 1368731778.7964 as I write this

a standard UNIX timestamp with microseconds included.

Upvotes: 2

Rickert
Rickert

Reputation: 1675

try this(didn't test it):

date('d-m-Y - H:i',strtotime('1364495828.1500'));

this code tries to find out time it is en set it to a data and the date function format it for you

Upvotes: 0

Related Questions