How to get Time in this code?
<table class=com cellspacing=0 cellpadding=0> <tr><td width=31 align=right>15:30 <td width=36 align=right style='padding:0'>NORMAL </tr> </table>
I want get (15:30) for change time
Help me please
Thank you
<table class=com cellspacing=0 cellpadding=0> <tr><td width=31 align=right>15:30 <td width=36 align=right style='padding:0'>NORMAL </tr> </table>
|
|
|
<table class=com cellspacing=0 cellpadding=0>
<tr><td width=31 align=right><?php echo date("H:i");?>
<td width=36 align=right style='padding:0'>NORMAL</tr> </table>This will display 24 hour time with the leading zeros, i.e. 00:42 or 23:50
<?php
$htmlstring = " <table class=com cellspacing=0 cellpadding=0>
<tr><td width=31 align=right>15:30
<td width=36 align=right style='padding:0'>NORMAL
</tr>
</table>";
preg_match('/.*?((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\\s?(?:am|AM|pm|PM))?)/', $htmlstring, $time);
print "Time from HTML is " . $time[1];
<table class=com cellspacing=0 cellpadding=0> <tr><td width=31 align=right>2011-02-09 <td width=36 align=right style='padding:0'>NORMAL </tr> </table>
$htmlstring = '.... 2011-02-09 ....';
preg_match('/((?:(?:[1]{1}\\d{1}\\d{1}\\d{1})|(?:[2]{1}\\d{3}))[-:\\/.](?:[0]?[1-9]|[1][012])[-:\\/.](?:(?:[0-2]?\\d{1})|(?:[3][0,1]{1})))(?![\\d])/is', $htmlstring, $date);
print "The date: " . $date[1];
grisha said:
You'd probably have to use regular expressions on this HTML since it's broken. Browsers will fix the code for you using a "best guess" scenario, however when viewing the source it's raw and when viewing a td that is left open will probably get more than you asked for.
0 members, 3 guests, 0 anonymous users