unix-timestamp

Datetime / Unix Date convertor

Datetime / Unix Date convertor Question: I need an input prompt that will allow the user to enter a date at the point the function is called and then run to concert the date to Unix date for an API call later in the program. At the moment every attempt seems to hand back an …

Total answers: 1

Generate epoch time

Generate epoch time Question: I want to convert my time_stamp string into epoch time but I am not good with datetime and related modules, so getting a little confused. I saw many solutions but none of them had date_time format like mine. my date_time is in the below format date_time = "2023-01-1T17:35:19.818" How can I …

Total answers: 1

adding any unix timestamp in discord.py

adding any unix timestamp in discord.py Question: i want to add unix timestamp in the giveaway time like in this image here is the code: @client.command() async def giveaway(ctx, days:int, hours:int, minutes:int, seconds:int, prize:str): time = days + hours + minutes + seconds embed = discord.Embed(title=prize, description=f"time: <t:{time}:R>") await ctx.send(embed=embed, delete_after=time) endembed = discord.Embed(title=f"you have …

Total answers: 1

How do I convert timestamp to unix format with pyspark

How do I convert timestamp to unix format with pyspark Question: I have a dataframe with timestamp values, like this one: 2018-02-15T11:39:13.000Z I want to have it in UNIX format, using Pyspark. I tried something like data = datasample.withColumn(‘timestamp_cast’, datasample[‘timestamp’].cast(‘date’)) but I lose a lot of information, since I only get day/month/year when I have …

Total answers: 2

How do I round down an epoch timestamp to the nearest minute in Python?

How do I round down an epoch timestamp to the nearest minute in Python? Question: I’d like to round down/floor an epoch/Unix timestamp so as to remove the seconds. I’m using Python 2.x and Python 3.x E.g. 1488728901 = Sun, 05 Mar 2017 15:48:21 GMT to: 1488728880 = Sun, 05 Mar 2017 15:48:00 GMT There’s …

Total answers: 3

Convert python datetime to timestamp in milliseconds

Convert python datetime to timestamp in milliseconds Question: How do I convert a human-readable time such as 20.12.2016 09:38:42,76 to a Unix timestamp in milliseconds? Asked By: Tom || Source Answers: In Python 3 this can be done in 2 steps: Convert timestring to datetime object Multiply the timestamp of the datetime object by 1000 …

Total answers: 7

Convert unix time to readable date in pandas dataframe

Convert unix time to readable date in pandas dataframe Question: I have a dataframe with unix times and prices in it. I want to convert the index column so that it shows in human readable dates. So for instance I have date as 1349633705 in the index column but I’d want it to show as …

Total answers: 5

python get time stamp on file in mm/dd/yyyy format

python get time stamp on file in mm/dd/yyyy format Question: I’m trying to get the datestamp on the file in mm/dd/yyyy format time.ctime(os.path.getmtime(file)) gives me detailed time stamp Fri Jun 07 16:54:31 2013 How can I display the output as 06/07/2013 Asked By: Ank || Source Answers: You want to use time.strftime() to format the …

Total answers: 3

Python Create unix timestamp five minutes in the future

Python Create unix timestamp five minutes in the future Question: I have to create an “Expires” value 5 minutes in the future, but I have to supply it in UNIX Timestamp format. I have this so far, but it seems like a hack. def expires(): ”’return a UNIX style timestamp representing 5 minutes from now”’ …

Total answers: 12