string datetime to datetime php string month code example Example: datetime get month php $dateTime = new DateTime(); $month = $dateTime->format('m');