I get the value so \/Date(770094000000-0300)\/
but I need to just recover the value 770094000000 to be able to convert to date.
I get the value so \/Date(770094000000-0300)\/
but I need to just recover the value 770094000000 to be able to convert to date.
You can use an ER, see an example on ideone .
$string = '/Date(770094000000-0300)/';
preg_match( "/([0-9]+)-([0-9]+)/" , $string , $match );
print_r( $match );
// output
array
(
[0] => 770094000000-0300
[1] => 770094000000
[2] => 0300
)
Simple solution for fixed numbering (the number will always be the same size).
$minha_string = '/Date(770094000000-0300)/';
$numero_desejado = substr($minha_string, 6, 12);
echo $numero_desejado; // irá exibir 770094000000
Solution using Regular Expressions.
$minha_string = '/Date(770094000000-0300)/';
preg_match('/\((\d+)/', $minha_string, $numero_desejado );
echo $numero_desejado[1]; // irá exibir 770094000000
You can use the preg_match function and get the values using a regular expression:
$str = '/Date(770094000000-0300)/';
preg_match( '/\d+\-\d+/', $str, $match );
var_dump( $match );