@piersg that's similar to what I was thinking. if I pass just the date the hours will be midnight by default. but it wasn't the case. even when I chose the hours as 0,0,0,0 it still wasn't the right hours. finally today I got the answer.
@EShumely If you want to convert that date (including the time) directly in to a unix timestamp in JS, you could do this
var date = '10/4/2021 16:10:23'
var unixDate = Math.floor(new Date(date).getTime() / 1000);
console.log(unixDate);
// returns "1633360223"
To follow up on @davidoff2drew's suggestion, if the data from Google is always a string in the format "10/4/2021 16:10:23" then you could use the HubL split filter to remove the time. e.g.
{% set dateAndTime = "10/4/2021 16:10:23" %}
{% set date = dateAndTime|split(' ') %}
{{date[0]}}
In JS, you can split a string like this:
var date = '10/4/2021 16:10:23'
console.log(date.split(" ")[0]);
// returns "10/4/2021"
@piersg that's similar to what I was thinking. if I pass just the date the hours will be midnight by default. but it wasn't the case. even when I chose the hours as 0,0,0,0 it still wasn't the right hours. finally today I got the answer.
@dennisedson Thanks 🙂 I'm using js. I've tried everything I could find. Thanks for the reference but I tried that too. tried this link as well https://www.epochconverter.com/
I think my lack of understanding of this object makes something very easy difficult for me.
firstly I don't know what date am I getting, I don't know what time zone it is. I don't know how to convert it to UTC (thought I found something but it didn't make any difference) I ended up using the error msg to get my UTC time and just hardcode the difference. but I don't need to mention this is a horrible solution.
@davidoff2drew Hi David, I don't like not being able to do something more than that, I don't like being told that something can't be done (someone from my team told me it's not possible so now I am invested).
as for passing it as string, how would you filter based on a date if you passed them as string?
I wouldn't be able to give you a function without knowing how you're building what you're building. But, you can either set the time to 00:00:00 (or whatever equals UTC midnight for you), or remove the time part of the string and just send in the date string.