Category "datetime"

Correctly determine if date string is a valid date in that format

I'm receiving a date string from an API, and it is formatted as yyyy-mm-dd. I am currently using a regex to validate the string format, which works ok, but I c

Not able to see all the methods under dt accessor in Jupyter notebook

Maybe a silly question. I have been trying to use dt accessor in pandas to use datetime methods on certain date fields in my Data Frame. Not sure why, but the a

Matplotlib and datetime error date2num function AttributeError

I'm trying to plot a graph with a list of datetime objects as one axis. I searched online and it seems I should call the date2num function. However, when I call

How to convert time from one timezone to another in PHP

I have a code see below. The time zone for the time 16:17 is Europe/Vilnius. My goal is to apply time zone $tz2 = 'Africa/Dakar' and get 16:17 time in Africa/Da

Date to String format in Firebird

How can I customize CAST (TimeStamp TO STRING) format in Firebird? cast (<DateField> as VarChar(25)) It does not work as I want. I do as I wish with t

How to check if a DateTime value is not null or empty?

I want to check if the DateTime field is not an empty\null string. if datetime field is not null then I will do stuff. [DateTime]$expdate = Read-Host "Expirati

Getting today's date in YYYY-MM-DD in Python?

Is there a nicer way than the following to return today's date in the YYYY-MM-DD format? str(datetime.datetime.today()).split()[0]

How to cast a datetime format to date as string in SQL Server

I am struggling to find a solution for the below issue. date1 = 31-08-2017 12:10:00 I want to cast it as string and need to take date (31-08-2017) alone. Th

What should I use instead of the deprecated Date.getHours()

If a method is deprecated in Java there will be a another better way to have same functionality, right? Date date = new Date(); date.getHours() As getHours()

Possible bug with getTransitions in PHP 8.1?

I know a lot of date-related bugs have been fixed in PHP 8.1, but it may have introduced new ones... Take this code: $time_zone_id = 'America/Vancouver'; $timeZ

How to change the datetime tick label frequency for matplotlib plots

Below shows a plot of simulated data, which contains the xticks that I want to modify. By default, the pd.df.plot chooses dates that are approximately 3 months

Laravel Carbon throws error The format separator does not match

I'm, trying to format a date into (Dayname Date Month) and I'm using Carbon for this but it return an error Carbon The format separator does not match here is a

Get current quarter in year with javascript

How can I get the current quarter we are in with javascript? I am trying to detect what quarter we are currently in, e.g. 2. EDIT And how can I count the numbe

How to get python to display current time (eastern)

How can I get Python to display the time in eastern? I've looked over the python documentation but it's pretty confusing. I'm using Python 3.

Adding two DateTime objects together

Is there any better way to add one DateTime object to another one, than this: DateTime first = new DateTime(2000, 1, 1); DateTime second = new DateTime(11, 2,

NameError: name 'UTC' is not defined

The output of datetime.datetime.now() outputs in my native timezone of UTC-8. I'd like to convert that to an appropriate timestamp with a tzinfo of UTC. from d

Python - Calculate the difference between two datetime.time objects

I have two datetime.time objects and I want to calculate the difference in hours between them. For example a = datetime.time(22,00,00) b = datetime.time(18,00,

Subtracting time.Duration from time in Go

I have a time.Time value obtained from time.Now() and I want to get another time which is exactly 1 month ago. I know subtracting is possible with time.Sub()

How to set multiple attributes for calender object at once?

This is my existing code snippet: Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.S

Serialize datetime.datetime object as JSON

Currently working on a quick little project in python and am attempting to encode an object into a JSON string. I've done this several times before without any