strptime

String to date conversion in PHP

空扰寡人 提交于 2019-12-11 17:25:42
问题 I'd like to convert such a date '2012 30 March 9:30 pm' into this format 2012-03-30 09:30:00 What is the easiest way to do that? I need it to be working on PHP 5.2 and older, so this solution isn't of any use for me date_format('Y-m-d H:M:S',date_create_from_format('Y m F g:i A', '2012 30 March 9:30 pm')) 回答1: This will extract each component from the date and rearrange it so that strtotime() understands. Convert to any date format you want after that. Using regex is probably overkill though.

strptime giving “implicit declaration” and “undefined reference”

≯℡__Kan透↙ 提交于 2019-12-11 12:35:43
问题 So, when I use the function strptime I get both a warning: warning: implicit declaration of function 'strptime' and an error after that: undefined reference to 'strptime' Yes, I've included time.h . Here is a small sample code of me using it. #include <time.h> void my_function() { char buf* = "2016-02-05 12:45:10"; struct tm time*; ... strptime(buf, "%F %T", &time); ... } I know time.h is working because in the same .c file, I'm using strftime , time_t , and 'struct tm from time.h without a

strptime, as.POSIXct and as.Date return unexpected NA

与世无争的帅哥 提交于 2019-12-11 10:06:17
问题 When I try to parse a timestamp in the following format: "Thu Nov 8 15:41:45 2012", only NA is returned. I am using Mac OS X, R 2.15.2 and Rstudio 0.97.237. The language of my OS is Dutch: I presume this has something to do with it. When I try strptime , NA is returned: var <- "Thu Nov 8 15:41:45 2012" strptime(var, "%a %b %d %H:%M:%S %Y") # [1] NA Neither does as.POSIXct work: as.POSIXct(var, "%a %b %d %H:%M:%S %Y") # [1] NA I also tried as.Date on the string above but without %H:%M:%S

Trouble using datetime.strptime()

北城以北 提交于 2019-12-11 04:29:58
问题 I have an Excel spreadsheet. I am trying to capture a line from the Excel sheet that contains a date, then parse the date out with datetime.strptime() . Here is the bit of the Excel sheet I'm working with: and my relevant code: pattern = re.compile(r'Listing(.+)', re.IGNORECASE) a = pattern.findall(str(df)) print("a:", a) new_a = str(a) datetime_object = datetime.strptime(new_a, '%b %w %Y') print("date:", datetime_object) So I capture everything that follows LISTING and produce: a: [' JUN 11

strptime in Javascript

拥有回忆 提交于 2019-12-11 03:37:32
问题 I have a date input field that allows the user to enter in a date and I need to validate this input (I already have server side validation), but the trick is that the format is locale dependent. I already have a system for translating the strptime format string to the the user's preference and I would like to use this same format for validating on the Javascript side. Any ideas or links to a strptime() implementation in Javascript? 回答1: After a few days of googling I found this implementation

Convert string to time with python [duplicate]

筅森魡賤 提交于 2019-12-10 23:54:49
问题 This question already has answers here : Parsing date/time string with timezone abbreviated name in Python? (5 answers) Closed 6 years ago . I have read a few stackoverflow posts but still can't figure this out... I want to crawl craigslist post posted within last 48 hours. Posted time is in the following format for craigslist: 2013-03-15, 7:43PM MDT I have tried string = "2013-03-15, 7:43PM MDT" time.strptime(string, "%Y-%m-%d, %I:%M%p %Z") But apparent the format doesnt match the string.

zoo/xts microsecond read issue

白昼怎懂夜的黑 提交于 2019-12-10 18:52:12
问题 The data looks like Time Set1 Set2 10:19:38.551629 16234 16236 10:19:41.408010 16234 16236 10:19:47.264204 16234 16236 I am trying to load this into zoo. orig <- read.zoo("~/sample.txt",sep="",header=TRUE,index.column=1,format="%H:%M:%S.%6f") Error in read.zoo("~/sample.txt", sep = "", header = TRUE, index.column = 1, : index has 3 bad entries at data rows: 1 2 3 ... I have checked all the relevant posts 1. R issue with rounding milliseconds 2. Milliseconds puzzle when calling strptime in R 3

Why is Time.strptime() returning the current date?

人走茶凉 提交于 2019-12-10 18:44:26
问题 Making a GET request to a private (no public documentation) API returns data in JSON format. The value im interested in is the date. It returns the date in ASP.NET JSON Date format. Here's what it looks like: AanmeldDatum: "/Date(1406675114000+0200)/" There's another variable called AangebodenSindsTekst which means OfferedSinceText and it's value is "8 augustus 2014". So the unknown Date format should get parsed into that specific value. I've tried this: require 'time' foo = Time.strptime(

ValueError: time data '24:00' does not match format '%H:%M'

梦想的初衷 提交于 2019-12-10 10:43:49
问题 I'm having serious trouble converting 24 hour time to 12 hour. def standard_time(t): t = datetime.strptime(t, "%H:%M") return t When fed in '24:00' we get ValueError: time data '24:00' does not match format '%H:%M' I also attempt converting using %I (12 hour) instead of %H, but get an error whenever hours go over 12: def standard_time(t): t = datetime.strptime(t, "%I:%M") return t Sort of stuck... ValueError: time data '13:30' does not match format '%I:%M' Does python have a simple 24 hour to

How do I specify POSIX (time) format for 3 letter tz in R, in order to ignore it?

半腔热情 提交于 2019-12-10 06:15:06
问题 For output, the specification is %Z (see ?strptime ). But for input, how does that work? To clarify, it'd be great for the time zone abbreviation to be parsed into useful information by as.POSIXct() , but more core to be question is how to get the function to at least ignore the time zone. Here is my best workaround, but is there a particular format code to pass to as.POSIXct() that will work for all time zones? times <- c("Fri Jul 03 00:15:00 EDT 2015", "Fri Jul 03 00:15:00 GMT 2015") as