If I view the page source of this website there is a piece of HTML that looks like:
<tr>
<td class="start-time text-right">2020-01-05T16:30:00Z</td>
<td>Pre-Show</td>
<td>Tech Crew</td>
<td rowspan="2" class="visible-lg text-center"> <i class="fa fa-clock-o text-gdq-red" aria-hidden="true"></i>
0:10:00 </td>
</tr>
If I get the start-time class's innerText with javascript then I get the string "10:30 AM".
This is not too surprising because it is the same as what is displayed in the browser:

But how can I get the original large timestamp and turn it into a date object?
In order to get a date object we need a day, a month, a year, a time in 24h format and a timezone
looking at the link you provided I can see they provided the dates inside .day-split, so with some simple text manipulation we are able to extract the needed info.
Javascript:
//data scaped from website::
var date = "Sunday, January 5th"; //from inside .day-split
var time = "10:30 AM"; // from inside .start-time
var timezone = "(detected as UTC+02:00)"; // from span #offset-detected
//data extraction and cleanup::
var day = parseInt(date.split(" ")[2]);
var month = date.split(" ")[1];
var year = new Date().getFullYear();
var time = convertTo24Hour(time)
var timezone = timezone.split(" ")[2].replace(")","")
// building the string and parsing it::
var dateString = [day, month, year, time, timezone].join(" ");
var dateObj = new Date(dateString);
// loging the output::
console.log(dateObj)
// a function used to convert time format (12H -> 24H)::
function convertTo24Hour(time) {
var hours = parseInt(time.substr(0, 2));
if (time.indexOf('AM') != -1 && hours == 12) {
time = time.replace('12', '0');
}
if (time.indexOf('PM') != -1 && hours < 12) {
time = time.replace(hours, (hours + 12));
}
return time.replace(/( AM| PM)/, '');
}
my answer assumes you already know how to scrape data from the website.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With