Jump to content

Recommended Posts

Hey

 

I am looking into a function that could grab the info between two characters what I have at the moment is a loop and in the loop I want to strip the time from the datetime stamp

 

default: 2009-08-12T01:00:00+01:00

 

 

so what I am trying to get is the variable between the T and the +

 

Could anyone point me in the right direction?

 

 

Thanks

 

I think you have to explode the information.

 

Here is an example of a date that I explode. The date came from a MySQL Database and saved in the format (Y-M-D)

 

 	if (isset($visitrow['Date'])) {
	$date = explode('-', $row['Date']);
	$month = $date[1];
	$day = $date[2];
	$year = $date[0];
	}

Using the datetime class you can extract any part you need:

 

$d = date_create('2009-08-12T01:00:00+01:00');
echo date_format($d, 'm/d/Y -- H:i:s P');

 

Look at date for the formatting strings....

 

Edit: (this is given you're using PHP 5.2+, if not there are still ways to do it - but this class has made it easier)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.