So @Jack Johansson and @Dave Romsey helped me to make it work.So I will put the solution here:
function ji_update_comment_date($comment,$commentarr){
$comment = get_comment( $comment );
$commentarr = array(
'comment_ID'=>$comment->comment_ID,
'comment_date'=>date("Y-m-d H:i:s"),
'comment_date_gmt'=> date("Y-m-d H:i:s")
);
wp_update_comment( $commentarr );}
add_action('comment_unapproved_to_approved','ji_update_comment_date');
I don’t understand why comment_ID() and get_comment_ID() won’t work in this scenario. But get_comment is surely a workaround.
Related Posts:
- How to deal with small scale comment spam on small commercial sites? [closed]
- Get comments for more than one post
- Add placeholder attribute to comment form fields
- human_time_diff() returns “48 years ago” for all comments
- “Categories” for comments?
- Allow anonymous comments, but prevent spam [closed]
- Where to remove from comment’s feed?
- Why are default comments deprecated?
- Comments Reply Form
- Allow guests comments on single post
- Delete all user comments
- Why do I get email notifications about comments that WordPress has already determined are spam?
- Delayed commenting
- “Leave a comment” link even when you can’t
- Display number of comment replies
- User can post only one comment per day on one page
- customize comment form
- How to check if commenter is the_author?
- Strategies for coping with hyperagressive spambots?
- Relaxing unescaped HTML filtering inside tags?
- How to save new comment as custom comment type?
- Should I still worry about paginated comments with the latest wordpress versions?
- WordPress unresponsive after calling wp_update_comment()
- edit comments capability for authors
- Publish a message on facebook after having posted a comment
- How can I edit the Twenty Ten Theme to remove the comments box when a page uses a specific template?
- Highlight Author Comments issues
- Users with custom roles can’t read each other’s comments
- Why is_wp_error() is not returning false even there’s no defined error
- Separete trackbacks/pings and numbered comments
- How can I fix wp_insert_comment failure when ‘comment_content” includes slanted apostrophe in Excel csv source data
- Show comments in a popup
- Is WordPress vulnerable to “comment posting forgery”?
- Author can only see own post comment and can moderate
- How to display html in only the first level of WP comments?
- Set noindex page-comment from Pages 2, 3 and More?
- How can I convert anonymous commenters into registered users?
- How can I edit comment notification email content?
- your comment awaiting moderation message sometimes not appearing
- Limit comments per user per post
- Filter In Reply comments from WordPress Admin Panel
- How can I hide the IP of registered commentators?
- Remove post navigation links
- How to automatically evaluate comment content without user seeing the delay?
- Notify post author for a new comment on his post?
- Allow the comment author to delete their own comments
- css hide all the comment reply links except the lowest nested comments
- Spammers attacking my WordPress Site – Removing URL field from core? [closed]
- Which filter/hook to use for styling comments?
- How should I get the original comment while processing the reply
- I wish to remove, disable or hide the comment authors’ links to their sites from my home page
- Admin can enter JavaScript – potential security risk?
- custom hooks before a comment is updated/edited in the database
- Replace comments with a dummy text
- How do I stop the comments going to my email?
- Disable only the comment form/box itself?
- anyone can help me to know whats going wrong? [closed]
- How to hide wordpress post comment form for specific role
- How to customize the title from comments form?
- How to display comment meta under each comment content
- Why there is still an approved comment after deleting all?
- get_comment_link without pagination base in the returned URL?
- Copy and Paste Password for Comments
- Returning error upon comment being flagged as spam
- is it possible to have the full code instead in the comments.php page
- JetPack comment threads are displaying above comment box? [closed]
- How do i remove approved spam comments by date?
- Remove Javascript generated by Comments
- Page comes up blank using w3 total cache [closed]
- Comment Table Size Results in Slow Page Loads and 500 Errors
- Insert ads between comments
- get_query_var(‘paged’) for WP_Comment_Query always return 1 when using paginate_comments_links()
- How to only show current user’s comments and comments on current user’s posts in wp admin
- How to make author comment name to “Editorial Staff” no matter which ever author is replying to comments from his/her account?
- How to show username in reply to comment?
- Custom sort comments with select form
- Display date and time into post edit comments section
- Disallowed Tag Present in AMP WordPress ()
- Comments/Discussion Not enabled on newly created posts/pages
- Fire Social Annex Code on Comment Approval
- How can I enable commenting from mobile view?
- Enable comments option
- Change Comment Text [duplicate]
- Comments closed but enabled on edit screen
- Let user delete comment on front end only
- jQuery to Create Button to Show/Hide WordPress Comments and to Hide Comments by Default
- Comment form – different title if no comment yet
- WordPress Comments jQuery Doesn’t submit
- Auto approve all comments (editor)
- add field comment [duplicate]
- Let users comment on categories in WordPress
- Loop not displaying comments_popup_link
- Display of comment_date within get_comments?
- How to batch convert comments to posts?
- prevent duplicate comments using wp_insert_comment
- I need help about wordpress of members section
- How to disable comments on new blog post, but allow on new products?
- Customize the new comment notifications sent to the post author after the comment is approved
- Get approved comments or comments that the author is me
- Show/Hide comments