Is there any function/code snippet to retrieve the unix time stamp of the comment on a post? The WordPress default function comment_time(); returns the time of the post in 12hr format (not helpful).
|
|
||||
|
|
|
Use:
Regards. |
|||||||
|
|
I know you've already selected an answer, but just a note based on your comments: there's a |
|||
|
|
|
Not sure about how or why you need the unix time stamp. You can get the ISO 8601 time stamp by using
This will output something like this
It may not be the unix timestamp, but at least you can use that to convert to a unix timestamp with php if you need to. Here is a PHP function to convert to UNIX timestamp. Taken from google calendar for simplepie plugin.
UpdateIf you want to get the relative time for comments, there is an easier way than trying to work out the time stamp in unix and doing all these conversions. Here are 2 functions I am using in the theme framework I am building that will do the job for you. First add this to the theme functions.
} Now you can get a relative time for any date format in worpdress.. either posts or comments. For comments you can do something like this in the comments code.
Or for post date, use this inside the loop.
From what I understand you want to do, this will work. It outputs the date and time as number of days, hours etc relative to today. eg: 45 seconds ago, or 1 day 1hr ago.. etc |
|||||||||||
|