1

I've date like this $input = '19/02/2013'.

How do I insert this date in my table (ISO 8601 format)?

Platform is SQL Server 2005 or SQL Server 2008.

Mike Fielden
  • 10,055
  • 14
  • 59
  • 99
Myaw
  • 61
  • 9
  • the topic they claim is a duplicate seems to provide a solution to an unsupported version of PHP, the solutions provided below are more current and sufficiently better advice than the other topic. – Eman Nov 22 '13 at 17:10

2 Answers2

1

Think this should do it.

$dt = new DateTime(strtotime($input));
echo $dt->format(DateTime::ISO8601);
akimsko
  • 904
  • 6
  • 7
1

You need to use some php functions to convert to sqlserver date format

$input = 19/02/2013;
$new_date = explode('/',$input);
$date = $new_date[2]-$new_date[1]-$new_date[0];

For ISO format you can use like this

$date->format(DateTime::ISO8601);
Php Geek
  • 1,107
  • 1
  • 15
  • 36
  • $newdate = date ('Y-m-d',strtotime(str_replace('/','-',$input))); /* format iSO ..*/ but I got an error when I try to insert this date on my table ... ]Conversion failed when converting date and/or time from character string. ) ) – Myaw Feb 18 '13 at 13:12