SlickRemix
SlickRemix

Reputation: 464

How do I get the timestamp for my date

The current code below returns my current local time in wordpress and the result looks like this. 2013-07-29 13:45:42

I need to convert this to a timestamp format. What is the answer please?

echo date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );

Upvotes: 1

Views: 7233

Answers (2)

SlickRemix
SlickRemix

Reputation: 464

Come to find out I really just needed the actual date and not a timestamp to achieve my goal. So using this gives you wordpress current local time that is set on the settings page in the admin panel.

date_i18n('Y-m-d');

Upvotes: 0

Joe Buckle
Joe Buckle

Reputation: 871

The PHP strtotime() function might work.

$timestamp = strtotime('2013-07-29 13:45:42');

EDIT Here is your use case

$current_date = date('Y-m-d H:i:s'); ## Get current date
$timestamp = strtotime($current_date); ## Get timestamp of current date
echo $timestamp; ## Print timestamp

Upvotes: 4

Related Questions