How to fix future relative time in dayjs? - dayjs

I have a code like this:
dayjs().to(post.date)
and it prints: 'in 6 hours'.
How to convert date to my timezone in dayjs?
thanks!

I'm not sure what you want. Guess you want to convert post.date timezone, you can do like dayjs().to(dayjs(post.date).tz("America/Toronto",true))
the document is on https://day.js.org/docs/en/timezone/timezone

Related

How to get filecreation timestamps as isodate

my script is checking for files in several directorys. If there is e.g. an mp3 I get the creation date via
time.ctime(os.path.getctime(audio_file_path))
What I need is an Isorepresentation of the date similar to
datetime.datetime.now().isoformat()
my result at the moment looks like this:
Thu May 28 13:58:45 2020
but what I need is this:
2020-06-03T13:36:48.740664"
Is there an easy way to transform the timestamp?
os.path.getctime returns a timestamp, so you can use:
datetime.datetime.fromtimestamp(os.path.getctime(audio_file_path)).isoformat()

momentjs endOf('month') does not deliver last day of month

When I invoke the following code
moment('2020-01-01T00:00:00Z').endOf('month').utc().format()
I get the result
'2020-01-01T07:59:59Z'
when I would have expected to see
'2020-01-31T23:59:59Z'
Is this a bug or am I not using the API correctly?
I think the problem is you used endOf before you convert the Date in UTC.
You pass this Date : 2020-01-01T00:00:00Z but the browser understand it with your timezone so the "real date" is 2019-12-31T15:00:00Z.
So you must convert it to UTC first and then proceed your change/call/etc.
So, I tried that and it worked ! Tell me if the problem persist.
moment('2020-01-01T00:00:00Z').utc().endOf('month').format()

why is output of date function on node.js server wrong?

When date was 2018-03-21 19:40, i tried following code
var date = new Date();
console.log(date);
Output :
2018-03-21T16:40:53.755Z
Server is missing for 3 hours as you see. I fixed it by adding 3 hours but I think it's not a good way. How can i fix this problem with better way ?
I don't think the date is incorrect, if you look closely at the format it is being printed, it has a Z at the end, which means:
A suffix which, when applied to a time, denotes a UTC offset of 00:00;
often spoken "Zulu" from the ICAO phonetic alphabet representation of
the letter "Z".
I guess you are in a place separated by 3 hours from UTC.
Node.js uses this format to print Date objects by default, but you can print your local time using toLocaleString():
console.log(date.toLocaleString());
Your server is most likely in another time zone.

Timex - Getting the timezone information from DateTime

I am looking for a way to get the timezone information back from a date time.
iex(13)> t = Timex.now("America/Los_Angeles")
#<DateTime(2016-10-23T12:45:34.697369-07:00 America/Los_Angeles)>
iex(14)> Timex.<given_t_return_timezone>??
Given t, I want back "America/Los_Angeles" again.
I knew it had to be easy. Rather than looking at Timex for this, we can simply do:
t.time_zone
This is part of Elixir itself since t is a DateTime.

String to Date Time Conversion in windows phone app

I am new to windows app development. I need to convert Date and Time available in String Format to dd/mm/yyyy and hh:mm format so that I can use it in setting the reminder.
thanks in advance......
I think you mean DateTime.Parse(string)
You can use like this
string ss=DateTime.Now.ToLongDateString();
For additional Information---
http://msdn.microsoft.com/en-us/library/system.datetime.tolongdatestring(v=vs.110).aspx

Resources