strftime

Outputting dates in non-ASCII characters with PHP

前提是你 提交于 2019-12-02 01:39:29
I'm trying to output the date in Traditional Chinese. I have the date as a Unix timestamp, ( example: "1467244800" ). I am doing the following: <?php setlocale (LC_TIME, "zh_TW"); echo strftime("%e %B %Y", $timestamp ); ?> What I'm getting output is the Unicode "Undefined" characters: 30 ���� 2016 17 �T�� 2016 18 �Q�G�� 2015 Can anyone tell me what I'm doing wrong? My HTML headers contain: <html lang="zh-TW"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> And the rest of my Chinese content on the page is outputting fine. If you view the page source you see: <span>最新消息<

Unicode setlocale and strftime fails at windows

故事扮演 提交于 2019-12-02 01:09:47
I have one page and it's encoding is UTF-8 and If i try to run that code in unix system everythings looks fine but when i try to run in windows(7) some chracters looks question mark(�). How can run the code fine both of two system(without using iconv). header('Content-Type: text/html; charset=UTF-8'); setlocale(LC_ALL, 'turkish'); echo strftime("%d %B %Y, %H:%M"); For those who is having similar problems on linux (this may work also for windows but not sure). Yes there is 'turkish' but there is also 'tr_TR.utf8' . If you use 'tr_TR.utf8' most probably your problems will be washed away. Same

how to compare strftime values

末鹿安然 提交于 2019-12-01 07:31:18
问题 I have two values created from strftime as below TIMEFORMAT="%Y-%m-%d %H:%M:%S" time1 = time.strftime(TIMEFORMAT) time2 = time.strftime(TIMEFORMAT) now the values of time1 and time 2 are like "2013-11-22 04:03:56" "2013-11-22 01:03:56" The values are written by other script to file. And I am reading these values back from file and then comparing. I want to compare something like this if time1 > time2: # do etc. etc. How to compare these times? 回答1: Yes, you can compare them. And, yes, t1 > t2

Converting to Local Time in R - Vector of Timezones

一笑奈何 提交于 2019-12-01 06:48:50
I have a set of data from across the US that I am trying to convert into local time for each "subject". I have UTC timestamps on each event and have converted those into POSIXct format, but every time I try to include a vector of tz = DS$Factor or tz = as.character(DS$Factor) in any of the POSIXct/POSIXlt functions (including format() and strftime() ) I get an error that says: Error in as.POSIXlt.POSIXct(x, tz = tz) : invalid 'tz' value If I just enter tz = 'US/Eastern' it works fine, but of course not all of my values are from that time zone. How do I get the time stamps into local time for

Convert strftime in SQLite request to MySQL

这一生的挚爱 提交于 2019-12-01 04:13:45
I converted the SQLite line WHERE strftime('%d%m', orders.created_at) = ....... directly to a MySQL monster: WHERE CONCAT(CAST(DAY(orders.created_at) AS CHAR), LPAD(CAST(MONTH(orders.created_at) AS CHAR), 2, '0')) = ......... Please, help me to rewrite it to a shorter one. STRFTIME() in SQLite is similar to DATE_FORMAT() in MySQL with reversed parameters. Since %d and %m map to the same thing in both, your expression can simply be written as; WHERE DATE_FORMAT(orders.created_at, '%d%m') = ....... 来源: https://stackoverflow.com/questions/24361074/convert-strftime-in-sqlite-request-to-mysql

Are 'US/Eastern' and 'US/Central' and 'US/Pacific' deprecated for strftime or just PHP?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 03:57:00
I have a shell script (zsh, to be precise) which uses strftime "%I:%M %p %Z (%a, %b %d)" "$EPOCHSECONDS" to generate a "current time" such as "02:45 PM CST (Thu, Mar 01)" This needs to be able to display the time in several different USA timezones, and so I have been using 'US/Eastern', 'US/Central', and 'US/Pacific' like so: export TZ='US/Eastern' strftime "%I:%M %p %Z (%a, %b %d)" "$EPOCHSECONDS" That seems to work just fine, and I prefer it to using TZ='America/CityName' because it doesn't require me to know which city is in which TZ, I just need to tell it which TZ I want. However, I

Convert strftime in SQLite request to MySQL

怎甘沉沦 提交于 2019-12-01 00:59:42
问题 I converted the SQLite line WHERE strftime('%d%m', orders.created_at) = ....... directly to a MySQL monster: WHERE CONCAT(CAST(DAY(orders.created_at) AS CHAR), LPAD(CAST(MONTH(orders.created_at) AS CHAR), 2, '0')) = ......... Please, help me to rewrite it to a shorter one. 回答1: STRFTIME() in SQLite is similar to DATE_FORMAT() in MySQL with reversed parameters. Since %d and %m map to the same thing in both, your expression can simply be written as; WHERE DATE_FORMAT(orders.created_at, '%d%m')

Are 'US/Eastern' and 'US/Central' and 'US/Pacific' deprecated for strftime or just PHP?

别说谁变了你拦得住时间么 提交于 2019-12-01 00:59:27
问题 I have a shell script (zsh, to be precise) which uses strftime "%I:%M %p %Z (%a, %b %d)" "$EPOCHSECONDS" to generate a "current time" such as "02:45 PM CST (Thu, Mar 01)" This needs to be able to display the time in several different USA timezones, and so I have been using 'US/Eastern', 'US/Central', and 'US/Pacific' like so: export TZ='US/Eastern' strftime "%I:%M %p %Z (%a, %b %d)" "$EPOCHSECONDS" That seems to work just fine, and I prefer it to using TZ='America/CityName' because it doesn't

Python time模块和datetime模块

半腔热情 提交于 2019-11-30 23:36:52
time模块 timetime模块提供各种时间相关的功能,与时间相关的模块有:time,datetime,calendar等。 时间有三种表示方式,一种是时间戳、一种是格式化时间、一种是时间元组。时间戳和格式化时间的相互转化,都需要先转化为时间元祖。 时间戳单位最适于做日期运算。但是1970年之前的日期就无法以此表示了。太遥远的日期也不行,UNIX和Windows只支持到2038年。 import time #导入time模块 time.sleep(30) #等待30秒 time.strftime('%Y-%m-%d %H:%M:%S') #当前的格式化时间 time.time()#返回当前的时间戳 import timeres =time.strftime('%y-%m-%d %X') # 获取当前年月日时分秒 res2 = time.strftime('%X') # 获取当前时间 res3 = time.strftime('%H:%M:%S') # 获取当前时间 print(res) # 19-10-09 21:49:34 print(res2) # 21:49:34 print(res3) # 21:49:34 时间戳转成格式化好的时间 import time time_tuple=time.gmtime(1556088065) #时间戳转成时间元祖

Spanish Characters not Displaying Correctly

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 15:12:52
问题 I am getting the lovely � box where spanish characters should be displayed. (ie: ñ, á, etc). I have already made sure that my meta http-equiv is set to utf-8: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> I have also made sure that the page header is set for utf-8 also: header('Content-type: text/html; charset=UTF-8'); Here is the beginning stages of my code thus far: <?php setlocale(LC_ALL, 'es_MX'); $datetime = strtotime($event['datetime']); $date = date("M j, Y",