Jump to content

PHP date


gary00ie

Recommended Posts

There may be a way to do this with a regular expression but I have no clue how to do that so I would do something like this..

 

<?php

//this case would be MM-DD-YYYY
if ((strpos($dateStr, "-") == 2) && (strrpos($dateStr, "-") == 5)
     //then strip off the last 4 characters

//this case would be YYYY-MM-DD
else if ((strpos($dateStr, "-") == 4) && (strrpos($dateStr, "-") == 7)
     //then strip off the first 4 characters

?>

 

would this work?

Link to comment
https://forums.phpfreaks.com/topic/248238-php-date/#findComment-1274778
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.