-1

I am working on soap EFS(electronic fund source)API. I have to get date form user which will be in mm-dd-yyyy and I have to pass this date as param in 2017-09-18T13:20:47-07:00 format.

How to convert data in 2017-09-18T13:20:47-07:00 format ?

David Coder
  • 1,138
  • 2
  • 14
  • 48
  • Please try unix_timestamp() given in: https://stackoverflow.com/questions/13625093/convert-mm-dd-yyyy-into-mysql-timestamp – Tavish Aggarwal Sep 21 '17 at 11:19
  • Possible duplicate of [Convert one date format into another in PHP](https://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php) – Qirel Sep 21 '17 at 11:23
  • @Qirel no pl see my question specially the date format. – David Coder Sep 21 '17 at 11:24
  • @TavishAggarwal unix_timestamp is mysql function. I have no database data i just want to convert date to given format. The date will come from POST data – David Coder Sep 21 '17 at 11:26
  • 1
    You wish to convert from one format to another, yes? That thread shows how. But if you just have `MM-DD-YYYY`, you're missing some information (the specific time), so you already have an issue there - you need to convert from a full datetime, otherwise it's assumed to be 00:00:00. – Qirel Sep 21 '17 at 11:26
  • @Qirel I have date in post data in this format (09-18-2017) I need to convert this date in 2017-09-18T13:20:47-07:00 this format. – David Coder Sep 21 '17 at 11:29
  • Yes, you said that already - but how can you get the time (not date)? How do you get `13:20:47`? Through magic? – Qirel Sep 21 '17 at 11:30
  • OK thats not the issue ok i will add it. So suppose i have date like 09-18-2017 13:20:47 then how can I get "T" and that -07:00 ? what is this ? – David Coder Sep 21 '17 at 11:35
  • 1
    See the flagged dupe :-) I suggest using a `DateTime` object, makes it easier. The `-07:00` is a timezone offset. – Qirel Sep 21 '17 at 11:38

1 Answers1

1

Try below method for convert Date for soap as per PHP DOCUMENT
Also, you have to pass time which is not in question. Below is not final answer but you can go throw something like this.

echo $dt->format('YY "-" MM "-" DD "T" HH ":" II ":" SS tzcorrection');
Ahmed Ginani
  • 6,522
  • 2
  • 15
  • 33