I'm working with the SparkPost API and I am having trouble understanding how to create a date with YYYY-MM-DDTHH:MM:SS+-HH:MM in PHP.
What is +-HH:MM, is that the timezone?
The closest I have come from reviewing other similar stack exchange topics is this:
if ( !$send_now && self::$row->datetime )
{
// This data is available: [send_datetime] => 04/01/2016 01:30
// This data is available: [timezone] => MDT-UTC-7
$send_at = date( 'Y-m-dTH:i:s' , strtotime( self::$row->datetime ) );
}
else
{
$send_at = 'now';
}
Another FYI is I am working with WordPress and will want to target the time zone the instance is set to.
Any help appreciated.
updated code that's working
if ( !$send_now && self::$row->datetime ) {
$send_at = date( 'c' , strtotime( self::$row->datetime ) );
if (isset(self::$email_settings['timezone'])) {
$date_parts = explode('+' , $send_at );
$timezone_parts = explode('UTC' , self::$email_settings['timezone'] );
$send_at = $date_parts[0] .$timezone_parts[1].':00';
}
} else {
$send_at = 'now';
}