Date time method

Hi,

I am trying to insert date and time into a table, see below:


$date = date(time());
$hours = date('h',$date);
$mins = date('m',$date);
$secs = date('s',$date);

$_POST['date'] = $_POST['year'].'-'.
$_POST['month'].'-'.$_POST['day'].' '.$hours.':'.$mins.':'.$secs;

The date is selected by the user via a calendar, it all works fine. But when i check the inserted row it inserts like this:

2010-09-20 03:09:55

The date is fine but the time is wrong, it should have added it like this:

2010-09-20 15:48:55

I think the time formate may be wrong? I need it to be in UK time format.

Any ideas how i can do this?

Thanks

As always Billy, you’re most welcome. :slight_smile:

For reference, you should have been using an upper-case H. Additionally, I’d also say the time element of the date string is probably not needed. Considering you’re making it up. :smiley:

That is so much simpler than what i had! :slight_smile:

Thanks

Crikey.


<?php
$date = sprintf(
  '&#37;04d-%02d-%02d %s',
  $_POST['year'],
  $_POST['month'],
  $_POST['day'],
  date('H:m:s')
);
?>